Add hidden form field
authorMatthias Schmidt <gravatronics@live.com>
Mon, 26 Aug 2019 17:39:13 +0000 (19:39 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 26 Aug 2019 17:39:13 +0000 (19:39 +0200)
Close #3053

com.woltlab.wcf/templates/__hiddenFormField.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/__hiddenFormField.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/system/form/builder/field/HiddenFormField.class.php [new file with mode: 0644]

diff --git a/com.woltlab.wcf/templates/__hiddenFormField.tpl b/com.woltlab.wcf/templates/__hiddenFormField.tpl
new file mode 100644 (file)
index 0000000..7f92db9
--- /dev/null
@@ -0,0 +1,5 @@
+<input type="hidden" {*
+       *}id="{@$field->getPrefixedId()}" {*
+       *}name="{@$field->getPrefixedId()}" {*
+       *}value="{$field->getValue()}"{*
+*}>
diff --git a/wcfsetup/install/files/acp/templates/__hiddenFormField.tpl b/wcfsetup/install/files/acp/templates/__hiddenFormField.tpl
new file mode 100644 (file)
index 0000000..7f92db9
--- /dev/null
@@ -0,0 +1,5 @@
+<input type="hidden" {*
+       *}id="{@$field->getPrefixedId()}" {*
+       *}name="{@$field->getPrefixedId()}" {*
+       *}value="{$field->getValue()}"{*
+*}>
diff --git a/wcfsetup/install/files/lib/system/form/builder/field/HiddenFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/HiddenFormField.class.php
new file mode 100644 (file)
index 0000000..ca6438d
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+namespace wcf\system\form\builder\field;
+
+/**
+ * Implementation of a form field for a hidden input field that is not visible in the rendered form.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2019 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Form\Builder\Field
+ * @since      5.2
+ */
+class HiddenFormField extends AbstractFormField {
+       /**
+        * @inheritDoc
+        */
+       protected $templateName = '__hiddenFormField';
+       
+       /**
+        * @inheritDoc
+        */
+       public function readValue() {
+               if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
+                       $this->value = $this->getDocument()->getRequestData($this->getPrefixedId());
+               }
+               
+               return $this;
+       }
+}