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