Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-30438 Lesson Module: improve password field to disabled when pass…

…word protect is set to no.
  • Loading branch information...
commit b3af55b363817df5cf449ac0090cc53e68cd60a6 1 parent 5c8860f
@rwijaya rwijaya authored
View
5 lib/form/passwordunmask.php
@@ -80,8 +80,11 @@ function toHtml() {
} else {
$unmask = get_string('unmaskpassword', 'form');
//Pass id of the element, so that unmask checkbox can be attached.
+ $attributes = array('formid' => $this->getAttribute('id'),
+ 'checkboxlabel' => $unmask,
+ 'checkboxname' => $this->getAttribute('name'));
$PAGE->requires->yui_module('moodle-form-passwordunmask', 'M.form.passwordunmask',
- array(array('formid' => $this->getAttribute('id'), 'checkboxname' => $unmask)));
+ array($attributes));
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />';
}
}
View
7 lib/form/yui/passwordunmask/passwordunmask.js
@@ -7,18 +7,19 @@ YUI.add('moodle-form-passwordunmask', function(Y) {
//Initialize checkbox if id is passed
initializer : function(params) {
if (params && params.formid) {
- this.add_checkbox(params.formid, params.checkboxname);
+ this.add_checkbox(params.formid, params.checkboxlabel, params.checkboxname);
}
},
//Create checkbox for unmasking password
- add_checkbox : function(elementid, checkboxlabel) {
+ add_checkbox : function(elementid, checkboxlabel, checkboxname) {
var node = Y.one('#'+elementid);
//retaining unmask div from previous implementation.
var unmaskdiv = Y.Node.create('<div id="'+elementid+'unmaskdiv" class="unmask"></div>');
//Add checkbox for unmasking to unmaskdiv
- var unmaskchb = Y.Node.create('<input id="'+elementid+'unmask" type="checkbox">');
+ var unmaskchb = Y.Node.create('<input id="'+elementid+'unmask" type="checkbox" name="'+
+ checkboxname+'unmask">');
unmaskdiv.appendChild(unmaskchb);
//Attach event using static javascript function for unmasking password.
unmaskchb.on('click', function() {unmaskPassword(elementid);});
View
1  mod/lesson/mod_form.php
@@ -133,6 +133,7 @@ function definition() {
$mform->setType('password', PARAM_RAW);
$mform->setAdvanced('password');
$mform->disabledIf('password', 'usepassword', 'eq', 0);
+ $mform->disabledIf('passwordunmask', 'usepassword', 'eq', 0);
$this->standard_grading_coursemodule_elements();
Please sign in to comment.
Something went wrong with that request. Please try again.