SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/AttrEditorTextbox.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. namespace Sprout\Helpers;
  15.  
  16.  
  17. /**
  18.  * Specialised text input field for page attributes
  19.  */
  20. class AttrEditorTextbox extends AttrEditor
  21. {
  22.  
  23. /**
  24.   * Return HTML for editing the attribute.
  25.   * Your attribute needs to return HTML for a single input element.
  26.   * The field name for the element needs to be 'value'.
  27.   *
  28.   * @param string $val The current value of the attribute
  29.   * @param string $attr_name The name of the attribute
  30.   **/
  31. public function render($val, $attr_name)
  32. {
  33. return '<div class="field-element field-element--text field-element--white">
  34. <div class="field-input">
  35. <input type="text" name="value" class="textbox" value="' . Enc::html($val) . '">
  36. </div>
  37. </div>
  38. ';
  39. }
  40.  
  41. }
  42.