MDL-59382 form: fix name in template context
authorRyan Wyllie <ryan@moodle.com>
Mon, 24 Jul 2017 06:59:39 +0000 (06:59 +0000)
committerRyan Wyllie <ryan@moodle.com>
Wed, 2 Aug 2017 04:47:42 +0000 (04:47 +0000)
lib/form/templatable_form_element.php
theme/boost/templates/core_form/element-template-inline.mustache

index 7d8c2ab..beb7173 100644 (file)
@@ -78,6 +78,7 @@ trait templatable_form_element {
                 $otherattributes[] = $attr . '="' . s($value) . '"';
             }
         }
+        $context['name'] = $context['name'] ?: $this->getName();
         $context['extraclasses'] = $extraclasses;
         $context['type'] = $this->getType();
         $context['attributes'] = implode(' ', $otherattributes);
index 88593fc..55e16c5 100644 (file)
@@ -4,7 +4,7 @@
         {{#required}}<abbr class="initialism text-danger" title="{{#str}}required{{/str}}">{{#pix}}req, core, {{#str}}required{{/str}}{{/pix}}</abbr>{{/required}}
         {{#advanced}}<abbr class="initialism text-info" title="{{#str}}advanced{{/str}}">!</abbr>{{/advanced}}
     </label>
-    <span data-fieldtype="{{element.type}}">
+    <span id="{{element.id}}" data-fieldtype="{{element.type}}">
         {{$ element }}
             <!-- Element goes here -->
         {{/ element }}