diff --git a/lib/form/password.php b/lib/form/password.php index 34aca13e856..5b5cae5ca12 100644 --- a/lib/form/password.php +++ b/lib/form/password.php @@ -19,9 +19,14 @@ class MoodleQuickForm_password extends HTML_QuickForm_password{ if (empty($CFG->xmlstrictheaders)) { // no standard mform in moodle should allow autocomplete of passwords // this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0 - $attributes = (array)$attributes; - if (!isset($attributes['autocomplete'])) { + if (empty($attributes)) { + $attributes = array('autocomplete'=>'off'); + } else if (is_array($attributes)) { $attributes['autocomplete'] = 'off'; + } else { + if (strpos($attributes, 'autocomplete') === false) { + $attributes .= ' autocomplete="off" '; + } } } diff --git a/lib/form/passwordunmask.php b/lib/form/passwordunmask.php index db8ae18410d..015f03470d1 100644 --- a/lib/form/passwordunmask.php +++ b/lib/form/passwordunmask.php @@ -19,9 +19,14 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password { if (empty($CFG->xmlstrictheaders)) { // no standard mform in moodle should allow autocomplete of passwords // this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0 - $attributes = (array)$attributes; - if (!isset($attributes['autocomplete'])) { + if (empty($attributes)) { + $attributes = array('autocomplete'=>'off'); + } else if (is_array($attributes)) { $attributes['autocomplete'] = 'off'; + } else { + if (strpos($attributes, 'autocomplete') === false) { + $attributes .= ' autocomplete="off" '; + } } } diff --git a/lib/formslib.php b/lib/formslib.php index 7fd05f06537..61772eae29d 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -110,9 +110,14 @@ class moodleform { if (empty($CFG->xmlstrictheaders)) { // no standard mform in moodle should allow autocomplete with the exception of user signup // this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0 - $attributes = (array)$attributes; - if (!isset($attributes['autocomplete'])) { + if (empty($attributes)) { + $attributes = array('autocomplete'=>'off'); + } else if (is_array($attributes)) { $attributes['autocomplete'] = 'off'; + } else { + if (strpos($attributes, 'autocomplete') === false) { + $attributes .= ' autocomplete="off" '; + } } }