MDL-77576 core: Add password unmask required field

The password unmask field will have the ability to
be a required field while used the required class.

Originally implemented as MDL-76701.

Co-Authored-By: Safat Shahin <[email protected]>
This commit is contained in:
Safat
2023-05-05 14:42:43 +10:00
parent ec5663f1a4
commit 37539dca0c
2 changed files with 28 additions and 0 deletions
+23
View File
@@ -4918,6 +4918,29 @@ class admin_setting_requiredtext extends admin_setting_configtext {
}
}
/**
* This type of field should be used for mandatory config settings where setting password is required.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_setting_requiredpasswordunmask extends admin_setting_configpasswordunmask {
/**
* Validate data before storage.
*
* @param string $data The string to be validated.
* @return bool|string true for success or error string if invalid.
*/
public function validate($data) {
$cleaned = clean_param($data, PARAM_TEXT);
if ($cleaned === '') {
return get_string('required');
}
return parent::validate($data);
}
}
/**
* Special text editor for site description.
*