diff --git a/lib/form/password.php b/lib/form/password.php index 14658e1e8f1..76404917165 100644 --- a/lib/form/password.php +++ b/lib/form/password.php @@ -57,9 +57,9 @@ class MoodleQuickForm_password extends HTML_QuickForm_password implements templa // no standard mform in moodle should allow autocomplete of passwords if (empty($attributes)) { $attributes = array('autocomplete'=>'off'); - } else if (is_array($attributes)) { + } else if (is_array($attributes) && empty($attributes['autocomplete'])) { $attributes['autocomplete'] = 'off'; - } else { + } else if (is_string($attributes)) { if (strpos($attributes, 'autocomplete') === false) { $attributes .= ' autocomplete="off" '; } diff --git a/login/change_password_form.php b/login/change_password_form.php index d1c978a13d4..63933875d74 100644 --- a/login/change_password_form.php +++ b/login/change_password_form.php @@ -58,11 +58,14 @@ class login_change_password_form extends moodleform { $mform->addRule('password', get_string('required'), 'required', null, 'client'); $mform->setType('password', PARAM_RAW); - $mform->addElement('password', 'newpassword1', get_string('newpassword')); + $mform->addElement('password', 'newpassword1', get_string('newpassword'), + ['autocomplete' => 'new-password']); $mform->addRule('newpassword1', get_string('required'), 'required', null, 'client'); $mform->setType('newpassword1', PARAM_RAW); - $mform->addElement('password', 'newpassword2', get_string('newpassword').' ('.get_String('again').')'); + $mform->addElement('password', 'newpassword2', + get_string('newpassword').' ('.get_String('again').')', + ['autocomplete' => 'new-password']); $mform->addRule('newpassword2', get_string('required'), 'required', null, 'client'); $mform->setType('newpassword2', PARAM_RAW); diff --git a/login/signup_form.php b/login/signup_form.php index 8dc535411e8..82e8fbdf01a 100644 --- a/login/signup_form.php +++ b/login/signup_form.php @@ -38,7 +38,6 @@ class login_signup_form extends moodleform implements renderable, templatable { $mform->addElement('header', 'createuserandpass', get_string('createuserandpass'), ''); - $mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12" autocapitalize="none"'); $mform->setType('username', PARAM_RAW); $mform->addRule('username', get_string('missingusername'), 'required', null, 'client'); @@ -46,7 +45,11 @@ class login_signup_form extends moodleform implements renderable, templatable { if (!empty($CFG->passwordpolicy)){ $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy()); } - $mform->addElement('password', 'password', get_string('password'), 'maxlength="32" size="12"'); + $mform->addElement('password', 'password', get_string('password'), [ + 'maxlength' => 32, + 'size' => 12, + 'autocomplete' => 'new-password' + ]); $mform->setType('password', core_user::get_property_type('password')); $mform->addRule('password', get_string('missingpassword'), 'required', null, 'client');