ButtonElement.php 778 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace dokuwiki\Form;
  3. /**
  4. * Class ButtonElement
  5. *
  6. * Represents a simple button
  7. *
  8. * @package dokuwiki\Form
  9. */
  10. class ButtonElement extends Element
  11. {
  12. /** @var string HTML content */
  13. protected $content = '';
  14. /**
  15. * @param string $name
  16. * @param string $content HTML content of the button. You have to escape it yourself.
  17. */
  18. public function __construct($name, $content = '')
  19. {
  20. parent::__construct('button', array('name' => $name, 'value' => 1));
  21. $this->content = $content;
  22. }
  23. /**
  24. * The HTML representation of this element
  25. *
  26. * @return string
  27. */
  28. public function toHTML()
  29. {
  30. return '<button ' . buildAttributes($this->attrs(), true) . '>'.$this->content.'</button>';
  31. }
  32. }