mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Let the admin choose if a textfield is to be shown as plain text or as a password (with '*' in place of normal text)
This commit is contained in:
parent
5011747062
commit
2803993c02
@ -527,6 +527,7 @@ $string['profilefieldtypemenu'] = 'Menu of choices';
|
||||
$string['profilefieldtypetext'] = 'Text input';
|
||||
$string['profilefieldtypetextarea'] = 'Text area';
|
||||
$string['profilefieldmaxlength'] = 'Maximum length';
|
||||
$string['profilefieldispassword'] = 'Is this a password field?';
|
||||
$string['profileforceunique'] = 'Should the data be unique?';
|
||||
$string['profileinvaliddata'] = 'Invalid value';
|
||||
$string['profilelocked'] = 'Is this field locked?';
|
||||
|
@ -16,8 +16,13 @@ class profile_define_text extends profile_define_base {
|
||||
$form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"');
|
||||
$form->setDefault('param2', 2048);
|
||||
$form->setType('param2', PARAM_INT);
|
||||
|
||||
/// Param 3 for text type detemines if this is a password field or not
|
||||
$form->addElement('selectyesno', 'param3', get_string('profilefieldispassword', 'admin'));
|
||||
$form->setDefault('param3', 0); // defaults to 'no'
|
||||
$form->setType('param3', PARAM_INT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -5,9 +5,10 @@ class profile_field_text extends profile_field_base {
|
||||
function edit_field_add(&$mform) {
|
||||
$size = $this->field->param1;
|
||||
$maxlength = $this->field->param2;
|
||||
$fieldtype = ($this->field->param3 == 1 ? 'password' : 'text');
|
||||
|
||||
/// Create the form field
|
||||
$mform->addElement('text', $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
|
||||
$mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
|
||||
$mform->setType($this->inputname, PARAM_MULTILANG);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user