You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

47 lines
953 B

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