[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

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

   1  <?php
   2  
   3  namespace dokuwiki\Form;
   4  
   5  /**
   6   * Class ValueElement
   7   *
   8   * Just like an Element but it's value is not part of its attributes
   9   *
  10   * What the value is (tag name, content, etc) is defined by the actual implementations
  11   *
  12   * @package dokuwiki\Form
  13   */
  14  abstract class ValueElement extends Element
  15  {
  16      /**
  17       * @var string holds the element's value
  18       */
  19      protected $value = '';
  20  
  21      /**
  22       * @param string $type
  23       * @param string $value
  24       * @param array $attributes
  25       */
  26      public function __construct($type, $value, $attributes = array())
  27      {
  28          parent::__construct($type, $attributes);
  29          $this->val($value);
  30      }
  31  
  32      /**
  33       * Get or set the element's value
  34       *
  35       * @param null|string $value
  36       * @return string|$this
  37       */
  38      public function val($value = null)
  39      {
  40          if ($value !== null) {
  41              $this->value = $value;
  42              return $this;
  43          }
  44          return $this->value;
  45      }
  46  
  47  }