[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Form/ -> TextareaElement.php (source)

   1  <?php
   2  namespace dokuwiki\Form;
   3  
   4  /**
   5   * Class TextareaElement
   6   * @package dokuwiki\Form
   7   */
   8  class TextareaElement extends InputElement {
   9  
  10      /**
  11       * @var string the actual text within the area
  12       */
  13      protected $text;
  14  
  15      /**
  16       * @param string $name The name of this form element
  17       * @param string $label The label text for this element
  18       */
  19      public function __construct($name, $label) {
  20          parent::__construct('textarea', $name, $label);
  21          $this->attr('dir', 'auto');
  22      }
  23  
  24      /**
  25       * Get or set the element's value
  26       *
  27       * This is the preferred way of setting the element's value
  28       *
  29       * @param null|string $value
  30       * @return string|$this
  31       */
  32      public function val($value = null) {
  33          if($value !== null) {
  34              $this->text = cleanText($value);
  35              return $this;
  36          }
  37          return $this->text;
  38      }
  39  
  40      /**
  41       * The HTML representation of this element
  42       *
  43       * @return string
  44       */
  45      protected function mainElementHTML() {
  46          if($this->useInput) $this->prefillInput();
  47          return '<textarea ' . buildAttributes($this->attrs()) . '>' .
  48          formText($this->val()) . '</textarea>';
  49      }
  50  
  51  }