From 8f0df229ed3e82191f118594ea5145c9d5942d7b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 18 Aug 2015 20:12:32 +0200 Subject: Form: added Button element #1312 --- inc/Form/ButtonElement.php | 34 ++++++++++++++++++++++++++++++++++ inc/Form/Form.php | 24 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 inc/Form/ButtonElement.php (limited to 'inc') diff --git a/inc/Form/ButtonElement.php b/inc/Form/ButtonElement.php new file mode 100644 index 000000000..77c30ed4f --- /dev/null +++ b/inc/Form/ButtonElement.php @@ -0,0 +1,34 @@ + $name, 'value' => 1)); + $this->content = $content; + } + + /** + * The HTML representation of this element + * + * @return string + */ + public function toHTML() { + return ''; + } + +} diff --git a/inc/Form/Form.php b/inc/Form/Form.php index 625557fa1..738f2bcf8 100644 --- a/inc/Form/Form.php +++ b/inc/Form/Form.php @@ -233,6 +233,30 @@ class Form extends Element { return $this->addElement(new TextareaElement($name, $label), $pos); } + /** + * Adds a simple button, escapes the content for you + * + * @param string $name + * @param string $content + * @param int $pos + * @return Element + */ + public function addButton($name, $content, $pos = -1) { + return $this->addElement(new ButtonElement($name, hsc($content)), $pos); + } + + /** + * Adds a simple button, allows HTML for content + * + * @param string $name + * @param string $html + * @param int $pos + * @return Element + */ + public function addButtonHTML($name, $html, $pos = -1) { + return $this->addElement(new ButtonElement($name, $html), $pos); + } + /** * Add fixed HTML to the form * -- cgit v1.2.3