MDL-55417 forms: Clean up form element template patch
authorDamyon Wiese <damyon@moodle.com>
Thu, 11 Aug 2016 09:16:59 +0000 (17:16 +0800)
committerDan Poltawski <dan@moodle.com>
Fri, 23 Sep 2016 09:53:30 +0000 (10:53 +0100)
Use a trait and a base mustache template for all form elements to reduce code
duplication and increase standardisation.

Part of MDL-55071

54 files changed:
lib/form/advcheckbox.php
lib/form/button.php
lib/form/checkbox.php
lib/form/editor.php
lib/form/filemanager.php
lib/form/filepicker.php
lib/form/grading.php
lib/form/group.php
lib/form/password.php
lib/form/radio.php
lib/form/recaptcha.php
lib/form/select.php
lib/form/selectgroups.php
lib/form/static.php
lib/form/submit.php
lib/form/templatable_form_element.php [new file with mode: 0644]
lib/form/text.php
lib/form/textarea.php
lib/form/url.php
lib/form/warning.php
theme/noname/scss/moodle/buttons.scss
theme/noname/templates/core_form/element-autocomplete.mustache
theme/noname/templates/core_form/element-button-inline.mustache
theme/noname/templates/core_form/element-button.mustache
theme/noname/templates/core_form/element-checkbox-inline.mustache
theme/noname/templates/core_form/element-checkbox.mustache
theme/noname/templates/core_form/element-date_selector.mustache
theme/noname/templates/core_form/element-date_time_selector-inline.mustache [new file with mode: 0644]
theme/noname/templates/core_form/element-date_time_selector.mustache
theme/noname/templates/core_form/element-duration-inline.mustache [new file with mode: 0644]
theme/noname/templates/core_form/element-editor.mustache
theme/noname/templates/core_form/element-filemanager.mustache
theme/noname/templates/core_form/element-filepicker.mustache
theme/noname/templates/core_form/element-grading.mustache
theme/noname/templates/core_form/element-group-inline.mustache [new file with mode: 0644]
theme/noname/templates/core_form/element-group.mustache
theme/noname/templates/core_form/element-password.mustache
theme/noname/templates/core_form/element-radio-inline.mustache [new file with mode: 0644]
theme/noname/templates/core_form/element-radio.mustache [new file with mode: 0644]
theme/noname/templates/core_form/element-recaptcha.mustache
theme/noname/templates/core_form/element-select-inline.mustache
theme/noname/templates/core_form/element-select.mustache
theme/noname/templates/core_form/element-selectgroups-inline.mustache
theme/noname/templates/core_form/element-selectgroups.mustache
theme/noname/templates/core_form/element-static.mustache
theme/noname/templates/core_form/element-submit-inline.mustache
theme/noname/templates/core_form/element-submit.mustache
theme/noname/templates/core_form/element-template-inline.mustache [new file with mode: 0644]
theme/noname/templates/core_form/element-template.mustache [new file with mode: 0644]
theme/noname/templates/core_form/element-text-inline.mustache
theme/noname/templates/core_form/element-text.mustache
theme/noname/templates/core_form/element-textarea.mustache
theme/noname/templates/core_form/element-url.mustache
theme/noname/templates/core_form/element-warning.mustache

index 00bcb17..979e789 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/advcheckbox.php');
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * HTML class for an advcheckbox type element
@@ -40,6 +40,9 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox implements templatable {
+
+    use templatable_form_element;
+
     /** @var string html for help button, if empty then no help will icon will be dispalyed. */
     var $_helpbutton='';
 
@@ -131,13 +134,4 @@ class MoodleQuickForm_advcheckbox extends HTML_QuickForm_advcheckbox implements
         }
         return $output;
     }
-
-    public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
-        return $context;
-    }
 }
index 3546f67..1229b38 100644 (file)
@@ -40,6 +40,8 @@ require_once(__DIR__ . '/../outputcomponents.php');
  */
 class MoodleQuickForm_button extends HTML_QuickForm_button implements templatable
 {
+    use templatable_form_element;
+
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
 
@@ -86,13 +88,4 @@ class MoodleQuickForm_button extends HTML_QuickForm_button implements templatabl
             return 'default';
         }
     }
-
-    public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
-        return $context;
-    }
 }
index 00ab240..83e6499 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/checkbox.php');
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * HTML class for a checkbox type element
@@ -41,6 +41,8 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox implements templatable {
+    use templatable_form_element;
+
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
 
@@ -139,13 +141,4 @@ class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox implements templa
         }
         return $output;
     }
-
-    public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
-        return $context;
-    }
 }
index 85d4f86..2049316 100644 (file)
@@ -30,7 +30,7 @@ global $CFG;
 require_once('HTML/QuickForm/element.php');
 require_once($CFG->dirroot.'/lib/filelib.php');
 require_once($CFG->dirroot.'/repository/lib.php');
-require_once($CFG->libdir.'/outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * Editor element
@@ -45,6 +45,10 @@ require_once($CFG->libdir.'/outputcomponents.php');
  * @todo      MDL-29426 ajax format conversion
  */
 class MoodleQuickForm_editor extends HTML_QuickForm_element implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string html for help button, if empty then no help will icon will be dispalyed. */
     public $_helpbutton = '';
 
@@ -451,11 +455,7 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element implements templatab
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
+        $context = $this->export_for_template_base($output);
         $context['html'] = $this->toHtml();
         return $context;
     }
index 7cde5ef..0cbf543 100644 (file)
@@ -30,7 +30,7 @@ global $CFG;
 require_once('HTML/QuickForm/element.php');
 require_once($CFG->dirroot.'/lib/filelib.php');
 require_once($CFG->dirroot.'/repository/lib.php');
-require_once($CFG->libdir.'/outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * Filemanager form element
@@ -42,6 +42,10 @@ require_once($CFG->libdir.'/outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_filemanager extends HTML_QuickForm_element implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string html for help button, if empty then no help will icon will be dispalyed. */
     public $_helpbutton = '';
 
@@ -300,11 +304,7 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element implements temp
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
+        $context = $this->export_for_template_base($output);
         $context['html'] = $this->toHtml();
         return $context;
     }
index b81a631..985879f 100644 (file)
@@ -29,7 +29,7 @@ global $CFG;
 
 require_once("HTML/QuickForm/button.php");
 require_once($CFG->dirroot.'/repository/lib.php');
-require_once($CFG->libdir.'/outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * Filepicker form element
@@ -42,6 +42,9 @@ require_once($CFG->libdir.'/outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_filepicker extends HTML_QuickForm_input implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
     /** @var string html for help button, if empty then no help will icon will be dispalyed. */
     public $_helpbutton = '';
 
@@ -223,11 +226,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input implements templat
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
+        $context = $this->export_for_template_base($output);
         $context['html'] = $this->toHtml();
         return $context;
     }
index d2aadee..af379c7 100644 (file)
@@ -28,7 +28,7 @@
 global $CFG;
 require_once("HTML/QuickForm/element.php");
 require_once($CFG->dirroot.'/grade/grading/form/lib.php');
-require_once($CFG->libdir.'/outputcomponents.php');
+require_once('templatable_form_element.php');
 
 if (class_exists('HTML_QuickForm')) {
     HTML_QuickForm::registerRule('gradingvalidated', 'callback', '_validate', 'MoodleQuickForm_grading');
@@ -49,6 +49,10 @@ if (class_exists('HTML_QuickForm')) {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_grading extends HTML_QuickForm_input implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
 
@@ -162,6 +166,8 @@ class MoodleQuickForm_grading extends HTML_QuickForm_input implements templatabl
     }
 
     public function export_for_template(renderer_base $output) {
-        return $this->toHtml();
+        $context = $this->export_for_template_base($output);
+        $context['html'] = $this->toHtml();
+        return $context;
     }
 }
index fbe4de8..c19b31b 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once("HTML/QuickForm/group.php");
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * HTML class for a form element group
@@ -39,6 +39,10 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_group extends HTML_QuickForm_group implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
 
@@ -153,15 +157,13 @@ class MoodleQuickForm_group extends HTML_QuickForm_group implements templatable
 
     public function export_for_template(renderer_base $output) {
         global $OUTPUT;
+
+        $context = $this->export_for_template_base($output);
+
         $this->_renderedfromtemplate = true;
 
         include_once('HTML/QuickForm/Renderer/Default.php');
 
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
         $elements = [];
         foreach ($this->_elements as $key => $element) {
             $element->_generateId();
index 1e57a0a..14658e1 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/password.php');
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * Password type form element
@@ -39,6 +39,8 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_password extends HTML_QuickForm_password implements templatable {
+    use templatable_form_element;
+
     /** @var string, html for help button, if empty then no help */
     var $_helpbutton='';
 
@@ -84,13 +86,4 @@ class MoodleQuickForm_password extends HTML_QuickForm_password implements templa
     function getHelpButton(){
         return $this->_helpbutton;
     }
-
-    public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
-        return $context;
-    }
 }
index 3f6a731..05a0c36 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/radio.php');
-
+require_once('templatable_form_element.php');
 /**
  * radio type form element
  *
@@ -37,7 +37,9 @@ require_once('HTML/QuickForm/radio.php');
  * @copyright 2006 Jamie Pratt <me@jamiep.org>
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class MoodleQuickForm_radio extends HTML_QuickForm_radio{
+class MoodleQuickForm_radio extends HTML_QuickForm_radio implements templatable {
+    use templatable_form_element;
+
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
 
index f086f84..b4cc756 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/input.php');
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * recaptcha type form element
@@ -39,6 +39,9 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_recaptcha extends HTML_QuickForm_input implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
 
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
@@ -155,11 +158,7 @@ class MoodleQuickForm_recaptcha extends HTML_QuickForm_input implements templata
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
+        $context = $this->export_for_template_base($output);
         $context['html'] = $this->toHtml();
         return $context;
     }
index 57c8504..219d4ee 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/select.php');
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * select type form element
@@ -39,6 +39,11 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_select extends HTML_QuickForm_select implements templatable {
+
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
 
@@ -192,15 +197,7 @@ class MoodleQuickForm_select extends HTML_QuickForm_select implements templatabl
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        $context['attributes'] = [];
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-            if (!in_array($name, ['id', 'name', 'multiple'])) {
-                $context['attributes'][] = ['name' => $name, 'value' => $value];
-            }
-        }
+        $context = $this->export_for_template_base($output);
 
         $options = [];
         foreach ($this->_options as $option) {
@@ -215,7 +212,6 @@ class MoodleQuickForm_select extends HTML_QuickForm_select implements templatabl
             $options[] = $o;
         }
         $context['options'] = $options;
-        $context['hideLabel'] = $this->_hiddenLabel;
 
         return $context;
     }
index b277138..6afa623 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/element.php');
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * select type form element
@@ -40,6 +40,10 @@ require_once(__DIR__ . '/../outputcomponents.php');
  */
 class MoodleQuickForm_selectgroups extends HTML_QuickForm_element implements templatable {
 
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var bool add choose option */
     var $showchoose = false;
 
@@ -510,15 +514,7 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element implements tem
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        $context['attributes'] = [];
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-            if (!in_array($name, ['id', 'name', 'multiple'])) {
-                $context['attributes'][] = ['name' => $name, 'value' => $value];
-            }
-        }
+        $context = $this->export_for_template_base($output);
         $optiongroups = [];
         if ($this->showchoose) {
             $optionsgroups[] = [
@@ -548,7 +544,6 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element implements tem
             $optiongroups[] = $og;
         }
         $context['optiongroups'] = $optiongroups;
-        $context['hideLabel'] = $this->_hiddenLabel;
 
         return $context;
     }
index d31329f..bd82163 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once("HTML/QuickForm/static.php");
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * Text type element
@@ -39,6 +39,10 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_static extends HTML_QuickForm_static implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string Form element type */
     var $_elementTemplateType='static';
 
@@ -85,11 +89,7 @@ class MoodleQuickForm_static extends HTML_QuickForm_static implements templatabl
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
+        $context = $this->export_for_template_base($output);
         $context['html'] = $this->toHtml();
         return $context;
     }
index 7ccd0cc..99712b0 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once("HTML/QuickForm/submit.php");
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * submit type form element
@@ -39,6 +39,10 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /**
      * constructor
      *
@@ -110,11 +114,7 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit implements templatabl
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
+        $context = $this->export_for_template_base($output);
         if ($this->getName() == 'cancel') {
             $context['iscancel'] = true;
         }
diff --git a/lib/form/templatable_form_element.php b/lib/form/templatable_form_element.php
new file mode 100644 (file)
index 0000000..2fa96ab
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Adds export_for_template behaviour to an mform element in a consistent and predictable way.
+ *
+ * @package   core_form
+ * @copyright 2016 Damyon Wiese
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+defined('MOODLE_INTERNAL') || die();
+
+// Some form elements are used before $CFG is created - do not rely on it here.
+require_once(__DIR__ . '/../outputcomponents.php');
+
+/**
+ * templatable_form_element trait.
+ *
+ * @package   core_form
+ * @copyright 2016 Damyon Wiese
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+trait templatable_form_element {
+
+    /**
+     * Function to export the renderer data in a format that is suitable for a
+     * mustache template. This means:
+     * 1. No complex types - only stdClass, array, int, string, float, bool
+     * 2. Any additional info that is required for the template is pre-calculated (e.g. capability checks).
+     *
+     * This trait can be used as-is for simple form elements - or imported with a different name
+     * so it can be extended with additional context variables before being returned.
+     *
+     * @param renderer_base $output Used to do a final render of any components that need to be rendered for export.
+     * @return stdClass|array
+     */
+    public function export_for_template(renderer_base $output) {
+        $context = [];
+
+        // Not all elements have all of these attributes - but they are common enough to be valid for a few.
+        $standardattributes = ['id', 'name', 'label', 'multiple', 'checked', 'error', 'size', 'value'];
+        $standardproperties = ['frozen', 'helpbutton', 'hiddenLabel'];
+
+        // Standard attributes.
+        foreach ($standardattributes as $attrname) {
+            $value = $this->getAttribute($attrname);
+            $context[$attrname] = $value;
+        }
+
+        // Standard class properties.
+        foreach ($standardproperties as $propname) {
+            $classpropname = '_' . $propname;
+            $context[strtolower($propname)] = isset($this->$classpropname) ? $this->$classpropname : false;
+        }
+
+        // Other attributes.
+        $otherattributes = [];
+        foreach ($this->getAttributes() as $attr => $value) {
+            if (!in_array($attr, $standardattributes)) {
+                $otherattributes[] = $attr . '="' . s($value) . '"';
+            }
+        }
+        $context['attributes'] = implode(' ', $otherattributes);
+
+        return $context;
+    }
+}
\ No newline at end of file
index 0264a99..e101dd0 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once("HTML/QuickForm/text.php");
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * Text type form element
@@ -39,6 +39,7 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_text extends HTML_QuickForm_text implements templatable {
+    use templatable_form_element;
 
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
@@ -127,13 +128,4 @@ class MoodleQuickForm_text extends HTML_QuickForm_text implements templatable {
         return $this->_helpbutton;
     }
 
-    public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
-        $context['hideLabel'] = $this->_hiddenLabel;
-        return $context;
-    }
 }
index 34ef9fe..eda6ede 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once('HTML/QuickForm/textarea.php');
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * Textarea type form element
@@ -39,6 +39,8 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_textarea extends HTML_QuickForm_textarea implements templatable {
+    use templatable_form_element;
+
     /** @var string Need to store id of form as we may need it for helpbutton */
     var $_formid = '';
 
@@ -131,14 +133,4 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea implements templa
             return 'default';
         }
     }
-
-    public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
-        $context['hideLabel'] = $this->_hiddenLabel;
-        return $context;
-    }
 }
index 47dfa7a..c372be0 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 require_once("HTML/QuickForm/text.php");
-require_once(__DIR__ . '/../outputcomponents.php');
+require_once('templatable_form_element.php');
 
 /**
  * url type form element
@@ -38,6 +38,10 @@ require_once(__DIR__ . '/../outputcomponents.php');
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class MoodleQuickForm_url extends HTML_QuickForm_text implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string html for help button, if empty then no help */
     var $_helpbutton='';
 
@@ -172,12 +176,8 @@ EOD;
     }
 
     public function export_for_template(renderer_base $output) {
-        $context = [];
-        $context['frozen'] = $this->_flagFrozen;
-        foreach ($this->getAttributes() as $name => $value) {
-            $context[$name] = $value;
-        }
-        $context['filepickerhtml'] = $this->getFilePickerHTML();
+        $context = $this->export_for_template_base($output);
+        $context['filepickerhtml'] = $this->toHtml();
         return $context;
     }
 }
index 38c21a3..fe7ec66 100644 (file)
@@ -25,6 +25,7 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 require_once("HTML/QuickForm/static.php");
+require_once('templatable_form_element.php');
 
 /**
  * static warning
@@ -36,7 +37,11 @@ require_once("HTML/QuickForm/static.php");
  * @copyright 2008 Jamie Pratt <me@jamiep.org>
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class MoodleQuickForm_warning extends HTML_QuickForm_static{
+class MoodleQuickForm_warning extends HTML_QuickForm_static implements templatable {
+    use templatable_form_element {
+        export_for_template as export_for_template_base;
+    }
+
     /** @var string Form element type */
     var $_elementTemplateType='warning';
 
@@ -99,4 +104,10 @@ class MoodleQuickForm_warning extends HTML_QuickForm_static{
     function getElementTemplateType(){
         return $this->_elementTemplateType;
     }
+
+    public function export_for_template(renderer_base $output) {
+        $context = $this->export_for_template_base($output);
+        $context['html'] = $this->toHtml();
+        return $context;
+    }
 }
index 36d8b43..df1df0e 100644 (file)
@@ -54,24 +54,6 @@ p.arrow_button {
     margin: 0 0 10px 5px;
 }
 
-input[name="searchwikicontent"] + input[type="submit"],
-select + input[type="submit"],
-input[type="text"] + input[type="button"],
-input[type="password"] + input[type="submit"],
-input[type="text"] + button,
-input[type="text"] + input[type="submit"] {
-    @extend .btn-lineup;
-}
-
-input.form-submit,
-input[type="button"],
-input[type="submit"],
-input[type="reset"] {
-    @extend .btn;
-    @extend .btn-secondary;
-    @extend .btn-lineup;
-}
-
 input {
     &.fp-btn-choose {
         @extend .btn-sm;
index 03ae368..75f93a1 100644 (file)
@@ -1,8 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9 form-inline">
+{{< core_form/element-template }}
+    {{$element}}
         <select class="custom-select {{#error}}form-control-danger{{/error}}" name="{{element.name}}"
             id="{{element.id}}"
             {{#element.multiple}}multiple{{/element.multiple}}
             {{#error}}
                 autofocus aria-describedby="id_error_{{element.name}}"
             {{/error}}
-            {{#element.attributes}}
-                {{name}}={{#quote}}{{value}}{{/quote}} ddd
-            {{/element.attributes}}
-            >
+            {{{element.attributes}}} >
             {{#element.options}}
             <option value="{{value}}" {{#selected}}selected{{/selected}}>{{text}}</option>
             {{/element.options}}
         </select>
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 96abc13..ed45cab 100644 (file)
@@ -1,11 +1,15 @@
-    <div class="form-group">
-        <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-            {{{label}}} {{{helpbutton}}}
-        </label>
+{{< core_form/element-template-inline }}
+    {{$element}}
         <button {{#element.frozen}}readonly{{/element.frozen}}
                 class="btn btn-secondary"
                 name="{{element.name}}"
-                id="{{element.id}}" >
+                id="{{element.id}}"
+                {{#error}}
+                    autofocus aria-describedby="id_error_{{element.name}}"
+                {{/error}}
+                {{{element.attributes}}}
+                >
                 {{{element.value}}}
         </button>
-    </div>
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template-inline }}
\ No newline at end of file
index 996a3cb..fe1d92f 100644 (file)
@@ -1,16 +1,14 @@
-<div class="form-group row">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9 form-inline">
+{{< core_form/element-template }}
+    {{$element}}
         <button {{#element.frozen}}readonly{{/element.frozen}}
                 class="btn btn-secondary m-l-0"
                 name="{{element.name}}"
                 id="{{element.id}}"
                 {{#error}}
                     autofocus aria-describedby="id_error_{{element.name}}"
-                {{/error}} >
+                {{/error}}
+                {{{element.attributes}}}>
                 {{{element.value}}}
                 </button>
-    </div>
-</div>
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 5400d74..15b0c5b 100644 (file)
@@ -4,7 +4,8 @@
     {{#element.frozen}}readonly disabled{{/element.frozen}}
     {{#error}}
         autofocus aria-describedby="id_error_{{element.name}}"
-    {{/error}} >
+    {{/error}}
+    {{{element.attributes}}} >
     {{{label}}} {{{helpbutton}}}
 </label>
 <span class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
index 5122bd9..78fdef8 100644 (file)
@@ -6,7 +6,7 @@
             {{#element.frozen}}readonly disabled{{/element.frozen}}
             {{#error}}
                 autofocus aria-describedby="id_error_{{element.name}}"
-            {{/error}} >
+            {{/error}} {{{element.attributes}}} >
             {{{label}}} {{{helpbutton}}}
         </label>
         <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
index 645b084..9d78aac 100644 (file)
@@ -1,10 +1,9 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9 form-inline fdate_selector">
+{{< core_form/element-template }}
+    {{$element}}
+        <div class="fdate_selector">
         {{#element.elements}}
             {{{.}}}
         {{/element.elements}}
-    </div>
-</div>
\ No newline at end of file
+        </div>
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
diff --git a/theme/noname/templates/core_form/element-date_time_selector-inline.mustache b/theme/noname/templates/core_form/element-date_time_selector-inline.mustache
new file mode 100644 (file)
index 0000000..1ba49a3
--- /dev/null
@@ -0,0 +1,9 @@
+{{< core_form/element-template-inline }}
+    {{$element}}
+        <div class="fdate_time_selector">
+        {{#element.elements}}
+            {{{.}}}
+        {{/element.elements}}
+        </div>
+    {{/element}}
+{{/ core_form/element-template-inline }}
\ No newline at end of file
index be63490..fa81373 100644 (file)
@@ -1,13 +1,9 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9 form-inline fdate_time_selector">
+{{< core_form/element-template }}
+    {{$element}}
+        <div class="fdate_time_selector">
         {{#element.elements}}
             {{{.}}}
         {{/element.elements}}
-    </div>
-    <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-        {{{error}}}
-    </div>
-</div>
\ No newline at end of file
+        </div>
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
diff --git a/theme/noname/templates/core_form/element-duration-inline.mustache b/theme/noname/templates/core_form/element-duration-inline.mustache
new file mode 100644 (file)
index 0000000..741703e
--- /dev/null
@@ -0,0 +1 @@
+{{> core_form/element-group-inline }}
\ No newline at end of file
index be56779..9006137 100644 (file)
@@ -1,33 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         {{{element.html}}}
-        <div class="form-control-feedback" id="id_error_{{element.name}}_5btext_5d" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 02403ac..9006137 100644 (file)
@@ -1,33 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         {{{element.html}}}
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 02403ac..9006137 100644 (file)
@@ -1,33 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         {{{element.html}}}
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 9c4e7b7..9006137 100644 (file)
@@ -1,33 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
-        {{{element}}}
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+{{< core_form/element-template }}
+    {{$element}}
+        {{{element.html}}}
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
diff --git a/theme/noname/templates/core_form/element-group-inline.mustache b/theme/noname/templates/core_form/element-group-inline.mustache
new file mode 100644 (file)
index 0000000..c7ff92d
--- /dev/null
@@ -0,0 +1,7 @@
+{{< core_form/element-template-inline }}
+    {{$element}}
+        {{#element.elements}}
+            {{{.}}}
+        {{/element.elements}}
+    {{/element}}
+{{/ core_form/element-template-inline }}
\ No newline at end of file
index d93f000..388e80b 100644 (file)
@@ -1,10 +1,7 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9 form-inline">
+{{< core_form/element-template }}
+    {{$element}}
         {{#element.elements}}
             {{{.}}}
         {{/element.elements}}
-    </div>
-</div>
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 8811260..3c0b252 100644 (file)
@@ -1,8 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         <input type="password"
                 {{#element.frozen}}readonly{{/element.frozen}}
                 class="form-control {{#error}}form-control-danger{{/error}}"
@@ -12,12 +9,9 @@
                 size="{{element.size}}"
                 {{#error}}
                     autofocus aria-describedby="id_error_{{element.name}}"
-                {{/error}} >
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
+                {{/error}} {{{attributes}}}>
+    {{/element}}
+{{/ core_form/element-template }}
 {{#js}}
 require(['core/yui'], function(Y) {
     Y.use('moodle-form-passwordunmask', function() {
@@ -26,24 +20,4 @@ require(['core/yui'], function(Y) {
                                 checkboxname: {{#quote}}{{element.name}}{{/quote}} });
     });
 });
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
 {{/js}}
\ No newline at end of file
diff --git a/theme/noname/templates/core_form/element-radio-inline.mustache b/theme/noname/templates/core_form/element-radio-inline.mustache
new file mode 100644 (file)
index 0000000..cc8fd3c
--- /dev/null
@@ -0,0 +1,33 @@
+<label class="form-check-inline {{#error}}has-danger{{/error}}">
+<input type="radio" name="{{element.name}}"
+    id="{{element.id}}" value="{{element.value}}" size="{{element.size}}"
+    {{#element.frozen}}readonly disabled{{/element.frozen}}
+    {{#error}}
+        autofocus aria-describedby="id_error_{{element.name}}"
+    {{/error}}
+    {{{element.attributes}}} >
+    {{{label}}} {{{helpbutton}}}
+</label>
+<span class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
+    {{{error}}}
+</span>
+{{#js}}
+require(['jquery', 'core/event'], function($, Event) {
+    var element = document.getElementById('{{element.id}}');
+    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
+        event.preventDefault();
+        var parent = $(element).closest('.form-group');
+        var feedback = parent.find('.form-control-feedback');
+        if (msg !== '') {
+            parent.addClass('has-danger');
+            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
+            feedback.html(msg);
+            feedback.show();
+        } else {
+            parent.removeClass('has-danger');
+            $(element).attr('aria-describedby', '');
+            feedback.hide();
+        }
+    });
+});
+{{/js}}
\ No newline at end of file
diff --git a/theme/noname/templates/core_form/element-radio.mustache b/theme/noname/templates/core_form/element-radio.mustache
new file mode 100644 (file)
index 0000000..8b74048
--- /dev/null
@@ -0,0 +1,36 @@
+<div class="form-group row {{#error}}has-danger{{/error}}">
+    <div class="col-md-9 push-md-3 checkbox">
+        <label>
+        <input type="radio" name="{{element.name}}"
+            id="{{element.id}}" value="{{element.value}}" size="{{element.size}}"
+            {{#element.frozen}}readonly disabled{{/element.frozen}}
+            {{#error}}
+                autofocus aria-describedby="id_error_{{element.name}}"
+            {{/error}} {{{element.attributes}}} >
+            {{{label}}} {{{helpbutton}}}
+        </label>
+        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
+            {{{error}}}
+        </div>
+    </div>
+</div>
+{{#js}}
+require(['jquery', 'core/event'], function($, Event) {
+    var element = document.getElementById('{{element.id}}');
+    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
+        event.preventDefault();
+        var parent = $(element).closest('.form-group');
+        var feedback = parent.find('.form-control-feedback');
+        if (msg !== '') {
+            parent.addClass('has-danger');
+            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
+            feedback.html(msg);
+            feedback.show();
+        } else {
+            parent.removeClass('has-danger');
+            $(element).attr('aria-describedby', '');
+            feedback.hide();
+        }
+    });
+});
+{{/js}}
\ No newline at end of file
index 02403ac..9006137 100644 (file)
@@ -1,33 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         {{{element.html}}}
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 97432a6..fb8063b 100644 (file)
@@ -1,7 +1,5 @@
-<div class="form-group {{#error}}has-danger{{/error}}">
-    <label for="{{element.id}}" class="{{#element.hideLabel}}sr-only{{/element.hideLabel}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
+{{< core_form/element-template-inline }}
+    {{$element}}
     <select class="custom-select {{#error}}form-control-danger{{/error}}" name="{{element.name}}"
         id="{{element.id}}"
         {{#element.multiple}}multiple{{/element.multiple}}
@@ -9,36 +7,10 @@
         {{#error}}
             autofocus aria-describedby="id_error_{{element.name}}"
         {{/error}}
-        {{#element.attributes}}
-            {{name}}={{#quote}}{{value}}{{/quote}}
-        {{/element.attributes}}>
+        {{element.attributes}} >
         {{#element.options}}
         <option value="{{value}}" {{#selected}}selected{{/selected}}>{{text}}</option>
         {{/element.options}}
     </select>
-    <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-        {{{error}}}
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template-inline }}
\ No newline at end of file
index 003d811..d556fa5 100644 (file)
@@ -1,8 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         <select class="custom-select {{#error}}form-control-danger{{/error}}" name="{{element.name}}"
             id="{{element.id}}"
             {{#element.multiple}}multiple{{/element.multiple}}
             {{#error}}
                 autofocus aria-describedby="id_error_{{element.name}}"
             {{/error}}
-            {{#element.attributes}}
-                {{name}}={{#quote}}{{value}}{{/quote}} ddd
-            {{/element.attributes}}
-            >
+            {{element.attributes}} >
             {{#element.options}}
             <option value="{{value}}" {{#selected}}selected{{/selected}}>{{text}}</option>
             {{/element.options}}
         </select>
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index f57bfe7..f08d6db 100644 (file)
@@ -1,7 +1,5 @@
-<div class="form-group {{#error}}has-danger{{/error}}">
-    <label for="{{element.id}}" class="{{#element.hideLabel}}sr-only{{/element.hideLabel}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
+{{< core_form/element-template-inline }}
+    {{$element}}
     <select class="form-control {{#error}}form-control-danger{{/error}}" name="{{element.name}}"
         id="{{element.id}}"
         {{#element.multiple}}multiple{{/element.multiple}}
@@ -9,36 +7,10 @@
         {{#error}}
             autofocus aria-describedby="id_error_{{element.name}}"
         {{/error}}
-        {{#element.attributes}}
-            {{name}}={{#quote}}{{value}}{{/quote}}
-        {{/element.attributes}}>
+        {{{#element.attributes}}} >
         {{#element.options}}
         <option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
         {{/element.options}}
     </select>
-    <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-        {{{error}}}
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template-inline }}
\ No newline at end of file
index 756f1e8..7390e5e 100644 (file)
@@ -1,8 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         <select class="form-control {{#error}}form-control-danger{{/error}}" name="{{element.name}}"
             id="{{element.id}}"
             {{#element.multiple}}multiple{{/element.multiple}}
@@ -10,10 +7,7 @@
             {{#error}}
                 autofocus aria-describedby="id_error_{{element.name}}"
             {{/error}}
-            {{#element.attributes}}
-                {{name}}={{#quote}}{{value}}{{/quote}}
-            {{/element.attributes}}
-            >
+            {{{#element.attributes}}} >
             {{#element.optiongroups}}
             <optgroup label="{{text}}">
             {{#options}}
             {{/element.optiongroups}}
             </optgroup>
         </select>
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 7963d86..9006137 100644 (file)
@@ -1,33 +1,5 @@
-<div class="form-group row fitem {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         {{{element.html}}}
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 425a5f9..f29ca3d 100644 (file)
@@ -1,10 +1,13 @@
-    <div class="form-group">
-        <label class="col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-            {{{label}}} {{{helpbutton}}}
-        </label>
+{{< core_form/element-template-inline }}
+    {{$element}}
         <input type="submit" {{#element.frozen}}readonly{{/element.frozen}}
-                class="btn btn-primary"
+                class="btn
+                    {{^element.iscancel}}btn-primary{{/element.iscancel}}
+                    {{#element.iscancel}}btn-secondary{{/element.iscancel}}
+                    {{#error}} btn-danger {{/error}}"
                 name="{{element.name}}"
                 id="{{element.id}}"
-                value="{{element.value}}" >
-    </div>
\ No newline at end of file
+                value="{{element.value}}"
+                {{{element.attributes}}} >
+    {{/element}}
+{{/ core_form/element-template-inline }}
\ No newline at end of file
index f6bb32e..2f7c9a7 100644 (file)
@@ -1,15 +1,16 @@
-<div class="form-group row">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9 form-inline">
+{{< core_form/element-template }}
+    {{$element}}
         <input type="submit" {{#element.frozen}}readonly{{/element.frozen}}
-                class="btn {{^iscancel}}btn-primary{{/iscancel}}{{#iscancel}}btn-secondary{{/iscancel}} m-l-0"
+                class="btn
+                    {{^element.iscancel}}btn-primary{{/element.iscancel}}
+                    {{#element.iscancel}}btn-secondary{{/element.iscancel}}
+                    {{#error}} btn-danger {{/error}}"
                 name="{{element.name}}"
                 id="{{element.id}}"
                 {{#error}}
                     autofocus aria-describedby="id_error_{{element.name}}"
                 {{/error}}
-                value="{{element.value}}">
-    </div>
-</div>
+                value="{{element.value}}"
+                {{{element.attributes}}} >
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
diff --git a/theme/noname/templates/core_form/element-template-inline.mustache b/theme/noname/templates/core_form/element-template-inline.mustache
new file mode 100644 (file)
index 0000000..5d4d9ac
--- /dev/null
@@ -0,0 +1,33 @@
+<div class="form-group {{#error}}has-danger{{/error}}">
+    <label class="col-form-label {{#element.hiddenlabel}}sr-only{{/element.hiddenlabel}}" for="{{element.id}}">
+        {{{label}}} {{{helpbutton}}}
+    </label>
+        {{$ element }}
+            <!-- Element goes here -->
+        {{/ element }}
+    <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
+        {{{error}}}
+    </div>
+</div>
+{{#js}}
+require(['jquery', 'core/event'], function($, Event) {
+    var element = document.getElementById('{{element.id}}');
+    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
+        event.preventDefault();
+        var parent = $(element).closest('.form-group');
+        var feedback = parent.find('.form-control-feedback');
+        if (msg !== '') {
+            parent.addClass('has-danger');
+            $(element).addClass('form-control-danger');
+            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
+            feedback.html(msg);
+            feedback.show();
+        } else {
+            parent.removeClass('has-danger');
+            $(element).removeClass('form-control-danger');
+            $(element).attr('aria-describedby', '');
+            feedback.hide();
+        }
+    });
+});
+{{/js}}
\ No newline at end of file
diff --git a/theme/noname/templates/core_form/element-template.mustache b/theme/noname/templates/core_form/element-template.mustache
new file mode 100644 (file)
index 0000000..34e1308
--- /dev/null
@@ -0,0 +1,35 @@
+<div class="form-group row {{#error}}has-danger{{/error}}">
+    <label class="col-md-3 col-form-label {{#element.hiddenlabel}}sr-only{{/element.hiddenlabel}}" for="{{element.id}}">
+        {{{label}}} {{{helpbutton}}}
+    </label>
+    <div class="col-md-9 form-inline">
+        {{$ element }}
+            <!-- Element goes here -->
+        {{/ element }}
+        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
+            {{{error}}}
+        </div>
+    </div>
+</div>
+{{#js}}
+require(['jquery', 'core/event'], function($, Event) {
+    var element = document.getElementById('{{element.id}}');
+    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
+        event.preventDefault();
+        var parent = $(element).closest('.form-group');
+        var feedback = parent.find('.form-control-feedback');
+        if (msg !== '') {
+            parent.addClass('has-danger');
+            $(element).addClass('form-control-danger');
+            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
+            feedback.html(msg);
+            feedback.show();
+        } else {
+            parent.removeClass('has-danger');
+            $(element).removeClass('form-control-danger');
+            $(element).attr('aria-describedby', '');
+            feedback.hide();
+        }
+    });
+});
+{{/js}}
\ No newline at end of file
index e18121d..45bab55 100644 (file)
@@ -1,7 +1,5 @@
-<div class="form-group {{#error}}has-danger{{/error}}">
-    <label class="{{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
+{{< core_form/element-template-inline }}
+    {{$element}}
     <input type="text"
             {{#element.frozen}}readonly{{/element.frozen}}
             class="form-control {{#error}}form-control-danger{{/error}}"
@@ -11,30 +9,7 @@
             size="{{element.size}}"
             {{#error}}
                 autofocus aria-describedby="id_error_{{element.name}}"
-            {{/error}} >
-    <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-        {{{error}}}
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+            {{/error}}
+            {{{element.attributes}}}>
+    {{/element}}
+{{/ core_form/element-template-inline }}
\ No newline at end of file
index 2dc6233..fc12344 100644 (file)
@@ -1,8 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         <input type="text"
                 {{#element.frozen}}readonly{{/element.frozen}}
                 class="form-control {{#error}}form-control-danger{{/error}}"
@@ -12,31 +9,7 @@
                 size="{{element.size}}"
                 {{#error}}
                     autofocus aria-describedby="id_error_{{element.name}}"
-                {{/error}} >
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+                {{/error}}
+                {{{element.attributes}}} >
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index ac463e9..999721e 100644 (file)
@@ -1,33 +1,13 @@
-<div class="form-group row fitem {{#error}}has-danger{{/error}}" id="fitem_{{element.id}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
-        <textarea name="{{element.name}}" id="{{element.id}}">{{element.value}}</textarea>
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+{{< core_form/element-template }}
+    {{$element}}
+        <textarea
+            name="{{element.name}}"
+            id="{{element.id}}"
+            {{#element.frozen}}readonly{{/element.frozen}}
+            class="form-control {{#error}}form-control-danger{{/error}}"
+            {{#error}}
+                autofocus aria-describedby="id_error_{{element.name}}"
+            {{/error}}
+            {{{element.attributes}}} >{{element.value}}</textarea>
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 88c6f01..36692c5 100644 (file)
@@ -1,8 +1,5 @@
-<div class="form-group row {{#error}}has-danger{{/error}}">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
+{{< core_form/element-template }}
+    {{$element}}
         <input type="url"
                 {{#element.frozen}}readonly{{/element.frozen}}
                 class="form-control {{#error}}form-control-danger{{/error}}"
@@ -12,32 +9,8 @@
                 size="{{element.size}}"
                 {{#error}}
                     autofocus aria-describedby="id_error_{{element.name}}"
-                {{/error}} >
+                {{/error}}
+                {{{element.attributes}}} >
                 {{{element.filepickerhtml}}}
-        <div class="form-control-feedback" id="id_error_{{element.name}}" {{^error}} style="display: none;"{{/error}}>
-            {{{error}}}
-        </div>
-    </div>
-</div>
-{{#js}}
-require(['jquery', 'core/event'], function($, Event) {
-    var element = document.getElementById('{{element.id}}');
-    $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) {
-        event.preventDefault();
-        var parent = $(element).closest('.form-group');
-        var feedback = parent.find('.form-control-feedback');
-        if (msg !== '') {
-            parent.addClass('has-danger');
-            $(element).addClass('form-control-danger');
-            $(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
-            feedback.html(msg);
-            feedback.show();
-        } else {
-            parent.removeClass('has-danger');
-            $(element).removeClass('form-control-danger');
-            $(element).attr('aria-describedby', '');
-            feedback.hide();
-        }
-    });
-});
-{{/js}}
\ No newline at end of file
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file
index 368b019..9006137 100644 (file)
@@ -1,10 +1,5 @@
-<div class="form-group row fitem has-danger">
-    <label class="col-md-3 col-form-label {{#element.hideLabel}}sr-only{{/element.hideLabel}}" for="{{element.id}}">
-        {{{label}}} {{{helpbutton}}}
-    </label>
-    <div class="col-md-9">
-        <div class="form-control-feedback" id="id_error_{{element.name}}">
-            {{{element.html}}}
-        </div>
-    </div>
-</div>
\ No newline at end of file
+{{< core_form/element-template }}
+    {{$element}}
+        {{{element.html}}}
+    {{/element}}
+{{/ core_form/element-template }}
\ No newline at end of file