MDL-36056 forms: Don't validate disabled fields
authorDamyon Wiese <damyon@moodle.com>
Tue, 5 Dec 2017 01:49:33 +0000 (09:49 +0800)
committerJun Pataleta <jun@moodle.com>
Wed, 6 Dec 2017 06:53:30 +0000 (19:53 +1300)
When fields are disabled, the value comes through as null so we need to specifically check for it
before validation.

lib/form/passwordunmask.php

index 224f756..e90ee4d 100644 (file)
@@ -101,8 +101,7 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
      * @return string|null Validation error message or null.
      */
     public function validateSubmitValue($value) {
-
-        if ($value !== trim($value)) {
+        if ($value !== null && $value !== trim($value)) {
             return get_string('err_wrappingwhitespace', 'core_form');
         }