xref: /dokuwiki/inc/Form/ButtonElement.php (revision 9d01c1d91a93cf50f37d1486481a6493e98be821)
18f0df229SAndreas Gohr<?php
2*9d01c1d9SSatoshi 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 */
12*9d01c1d9SSatoshi Saharaclass ButtonElement extends Element
13*9d01c1d9SSatoshi 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     */
21*9d01c1d9SSatoshi Sahara    public function __construct($name, $content = '')
22*9d01c1d9SSatoshi Sahara    {
238f0df229SAndreas Gohr        parent::__construct('button', array('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     */
32*9d01c1d9SSatoshi Sahara    public function toHTML()
33*9d01c1d9SSatoshi Sahara    {
347dfce451SAnika Henke        return '<button ' . buildAttributes($this->attrs(), true) . '>'.$this->content.'</button>';
358f0df229SAndreas Gohr    }
368f0df229SAndreas Gohr
378f0df229SAndreas Gohr}
38