summaryrefslogtreecommitdiff
path: root/inc/Form/TextareaElement.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2015-05-08 16:15:16 +0200
committerAndreas Gohr <andi@splitbrain.org>2015-05-08 16:15:16 +0200
commit12a4e4d1ed827c59290838d5a11d75ad32aa28f1 (patch)
tree0fa3fe9326391a24c5eef384b4882580bab3a2e1 /inc/Form/TextareaElement.php
parentcffb4528cea1b9e7e03dc724aaa9719dbd6e23c9 (diff)
downloadrpg-12a4e4d1ed827c59290838d5a11d75ad32aa28f1.tar.gz
rpg-12a4e4d1ed827c59290838d5a11d75ad32aa28f1.tar.bz2
start of rewriting the form handling
This is jsut a small beginning. Not all elements are there, yet. It's also completely untested so far.
Diffstat (limited to 'inc/Form/TextareaElement.php')
-rw-r--r--inc/Form/TextareaElement.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/inc/Form/TextareaElement.php b/inc/Form/TextareaElement.php
new file mode 100644
index 000000000..a8486266f
--- /dev/null
+++ b/inc/Form/TextareaElement.php
@@ -0,0 +1,50 @@
+<?php
+namespace dokuwiki\Form;
+
+/**
+ * Class TextareaElement
+ * @package dokuwiki\Form
+ */
+class TextareaElement extends InputElement {
+
+ /**
+ * @var string the actual text within the area
+ */
+ protected $text;
+
+ /**
+ * @param string $name The name of this form element
+ * @param string $label The label text for this element
+ */
+ public function __construct($name, $label) {
+ parent::__construct('textarea', $name, $label);
+ }
+
+ /**
+ * Get or set the element's value
+ *
+ * This is the preferred way of setting the element's value
+ *
+ * @param null|string $value
+ * @return string|$this
+ */
+ public function val($value = null) {
+ if($value !== null) {
+ $this->text = $value;
+ return $this;
+ }
+ return $this->text;
+ }
+
+ /**
+ * The HTML representation of this element
+ *
+ * @return string
+ */
+ protected function mainElementHTML() {
+ if($this->useInput) $this->prefillInput();
+ return '<textarea ' . buildAttributes($this->attrs()) . '>' .
+ formText($this->val()) . '</textarea>';
+ }
+
+}