MDL-55657 theme_noname: Use a separate template for passwordunmask
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 26 Aug 2016 00:29:43 +0000 (08:29 +0800)
committerDan Poltawski <dan@moodle.com>
Fri, 23 Sep 2016 09:55:14 +0000 (10:55 +0100)
Part of MDL-55071

lib/form/passwordunmask.php
theme/noname/templates/core_form/element-password.mustache
theme/noname/templates/core_form/element-passwordunmask.mustache [new file with mode: 0644]

index b8d4102..73bee9d 100644 (file)
@@ -65,6 +65,7 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
         }
 
         parent::__construct($elementName, $elementLabel, $attributes);
+        $this->setType('passwordunmask');
     }
 
     /**
index 8d6d191..ac1da19 100644 (file)
                 {{/error}} {{{attributes}}}>
     {{/element}}
 {{/ core_form/element-template }}
-{{#js}}
-require(['core/yui'], function(Y) {
-    Y.use('moodle-form-passwordunmask', function() {
-        M.form.passwordunmask({ formid: {{#quote}}{{element.id}}{{/quote}},
-                                checkboxlabel: {{#quote}}{{#str}}unmaskpassword, form{{/str}}{{/quote}},
-                                checkboxname: {{#quote}}{{element.name}}{{/quote}} });
-    });
-});
-{{/js}}
diff --git a/theme/noname/templates/core_form/element-passwordunmask.mustache b/theme/noname/templates/core_form/element-passwordunmask.mustache
new file mode 100644 (file)
index 0000000..8d6d191
--- /dev/null
@@ -0,0 +1,23 @@
+{{< core_form/element-template }}
+    {{$element}}
+        <input type="password"
+                {{#element.frozen}}readonly{{/element.frozen}}
+                class="form-control {{#error}}form-control-danger{{/error}}"
+                name="{{element.name}}"
+                id="{{element.id}}"
+                value="{{element.value}}"
+                size="{{element.size}}"
+                {{#error}}
+                    autofocus aria-describedby="id_error_{{element.name}}"
+                {{/error}} {{{attributes}}}>
+    {{/element}}
+{{/ core_form/element-template }}
+{{#js}}
+require(['core/yui'], function(Y) {
+    Y.use('moodle-form-passwordunmask', function() {
+        M.form.passwordunmask({ formid: {{#quote}}{{element.id}}{{/quote}},
+                                checkboxlabel: {{#quote}}{{#str}}unmaskpassword, form{{/str}}{{/quote}},
+                                checkboxname: {{#quote}}{{element.name}}{{/quote}} });
+    });
+});
+{{/js}}