Skip to content

Commit

Permalink
Let the admin choose if a textfield is to be shown as plain text or a…
Browse files Browse the repository at this point in the history
…s a password (with '*' in place of normal text)
  • Loading branch information
scyrma committed Dec 21, 2007
1 parent 5011747 commit 2803993
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions lang/en_utf8/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@
$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?';
Expand Down
7 changes: 6 additions & 1 deletion user/profile/field/text/define.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ function define_form_specific(&$form) {
$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);
}

}

?>
?>
3 changes: 2 additions & 1 deletion user/profile/field/text/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2803993

Please sign in to comment.