xref: /dokuwiki/inc/Form/ButtonElement.php (revision 90fb952c4c30c09c8446076ba05991c89a3f0b01)
18f0df229SAndreas Gohr<?php
29d01c1d9SSatoshi Sahara
38f0df229SAndreas Gohrnamespace dokuwiki\Form;
48f0df229SAndreas Gohr
58f0df229SAndreas Gohr/**
68f0df229SAndreas Gohr * Class ButtonElement
78f0df229SAndreas Gohr *
88f0df229SAndreas Gohr * Represents a simple button
98f0df229SAndreas Gohr *
108f0df229SAndreas Gohr * @package dokuwiki\Form
118f0df229SAndreas Gohr */
129d01c1d9SSatoshi Saharaclass ButtonElement extends Element
139d01c1d9SSatoshi Sahara{
148f0df229SAndreas Gohr    /** @var string HTML content */
158f0df229SAndreas Gohr    protected $content = '';
168f0df229SAndreas Gohr
178f0df229SAndreas Gohr    /**
188f0df229SAndreas Gohr     * @param string $name
198f0df229SAndreas Gohr     * @param string $content HTML content of the button. You have to escape it yourself.
208f0df229SAndreas Gohr     */
219d01c1d9SSatoshi Sahara    public function __construct($name, $content = '')
229d01c1d9SSatoshi Sahara    {
23*6fd0861fSAndreas Gohr        parent::__construct('button', ['name' => $name, 'value' => 1]);
248f0df229SAndreas Gohr        $this->content = $content;
258f0df229SAndreas Gohr    }
268f0df229SAndreas Gohr
278f0df229SAndreas Gohr    /**
288f0df229SAndreas Gohr     * The HTML representation of this element
298f0df229SAndreas Gohr     *
308f0df229SAndreas Gohr     * @return string
318f0df229SAndreas Gohr     */
329d01c1d9SSatoshi Sahara    public function toHTML()
339d01c1d9SSatoshi Sahara    {
347dfce451SAnika Henke        return '<button ' . buildAttributes($this->attrs(), true) . '>' . $this->content . '</button>';
358f0df229SAndreas Gohr    }
368f0df229SAndreas Gohr}
37