xref: /dokuwiki/inc/Form/ButtonElement.php (revision 7dfce4513e19c578c35ec2af447e40e57a26cc97)
18f0df229SAndreas Gohr<?php
28f0df229SAndreas Gohrnamespace dokuwiki\Form;
38f0df229SAndreas Gohr
48f0df229SAndreas Gohr/**
58f0df229SAndreas Gohr * Class ButtonElement
68f0df229SAndreas Gohr *
78f0df229SAndreas Gohr * Represents a simple button
88f0df229SAndreas Gohr *
98f0df229SAndreas Gohr * @package dokuwiki\Form
108f0df229SAndreas Gohr */
118f0df229SAndreas Gohrclass ButtonElement extends Element {
128f0df229SAndreas Gohr
138f0df229SAndreas Gohr    /** @var string HTML content */
148f0df229SAndreas Gohr    protected $content = '';
158f0df229SAndreas Gohr
168f0df229SAndreas Gohr    /**
178f0df229SAndreas Gohr     * @param string $name
188f0df229SAndreas Gohr     * @param string $content HTML content of the button. You have to escape it yourself.
198f0df229SAndreas Gohr     */
208f0df229SAndreas Gohr    function __construct($name, $content = '') {
218f0df229SAndreas Gohr        parent::__construct('button', array('name' => $name, 'value' => 1));
228f0df229SAndreas Gohr        $this->content = $content;
238f0df229SAndreas Gohr    }
248f0df229SAndreas Gohr
258f0df229SAndreas Gohr    /**
268f0df229SAndreas Gohr     * The HTML representation of this element
278f0df229SAndreas Gohr     *
288f0df229SAndreas Gohr     * @return string
298f0df229SAndreas Gohr     */
308f0df229SAndreas Gohr    public function toHTML() {
31*7dfce451SAnika Henke        return '<button ' . buildAttributes($this->attrs(), true) . '>'.$this->content.'</button>';
328f0df229SAndreas Gohr    }
338f0df229SAndreas Gohr
348f0df229SAndreas Gohr}
35