Add `IFormNode::getHtmlVariables()`
authorMatthias Schmidt <gravatronics@live.com>
Mon, 1 Jan 2018 08:37:37 +0000 (09:37 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 1 Jan 2018 08:37:37 +0000 (09:37 +0100)
See #2509

wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php
wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php
wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php
wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php
wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php

index 1fdd2e9082697b1c24894a718292056dddcb0657..2f71220efda99c5aff35204c42435b19e3a6000b 100644 (file)
@@ -124,9 +124,9 @@ class FormDocument implements IFormDocument {
         * @inheritDoc
         */
        public function getHtml() {
-               return WCF::getTPL()->fetch('__form', 'wcf', [
+               return WCF::getTPL()->fetch('__form', 'wcf', array_merge($this->getHtmlVariables(), [
                        'form' => $this
-               ]);
+               ]));
        }
        
        /**
index 7c0a268ae50ac701d0ce073da89614c28159fc44..4fabf114d3f923db7e955360bd5c12f99535e9ba 100644 (file)
@@ -68,12 +68,20 @@ interface IFormNode {
        public function getDocument();
        
        /**
-        * Returns the HTML representation of this node.
+        * Returns the html representation of this node.
         *
-        * @return      string          HTML representation of node
+        * @return      string          html representation of node
         */
        public function getHtml();
        
+       /**
+        * Returns additional template variables used to generate the html representation
+        * of this node.
+        * 
+        * @return      array           additional template variables
+        */
+       public function getHtmlVariables();
+       
        /**
         * Returns the id of the form node.
         * 
index 588ba229aacd06d2bada910cc2c10dc025b9ec85..7157b143490845d9d9d5e9d5f65cc7cc8d6eab82 100644 (file)
@@ -119,6 +119,16 @@ trait TFormNode {
         */
        abstract public function getDocument();
        
+       /**
+        * Returns additional template variables used to generate the html representation
+        * of this node.
+        *
+        * @return      array           additional template variables
+        */
+       public function getHtmlVariables() {
+               return [];
+       }
+       
        /**
         * Returns the id of the form node.
         *
index faa39c3258d1318f60a0a546c440cf49ca44f456..d1a76b7ce3247b4290d12fcc5932e7e6d843c4f5 100644 (file)
@@ -33,9 +33,9 @@ class FormContainer implements IFormContainer {
         * @inheritDoc
         */
        public function getHtml() {
-               return WCF::getTPL()->fetch($this->templateName, 'wcf', [
+               return WCF::getTPL()->fetch($this->templateName, 'wcf', array_merge($this->getHtmlVariables(), [
                        'container' => $this
-               ], true);
+               ]), true);
        }
        
        /**
index db9a235190f913d4eaa6a4d56e99b1569789b05f..27564ff0a9c2affcb3107cebe39c8d5bba8571e4 100644 (file)
@@ -109,7 +109,7 @@ abstract class AbstractFormField implements IFormField {
                return WCF::getTPL()->fetch(
                        $this->templateName,
                        'wcf',
-                       ['field' => $this],
+                       array_merge($this->getHtmlVariables(), ['field' => $this]),
                        true
                );
        }