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:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user