mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-8096 - some more fixes for custom profile fields
This commit is contained in:
parent
0a5c8ca42c
commit
1bf65e5880
@ -23,11 +23,11 @@ class profile_define_base {
|
||||
|
||||
$strrequired = get_string('required');
|
||||
|
||||
$form->addElement('text', 'shortname', get_string('profileshortname', 'admin'), 'maxlength="100" size="30"');
|
||||
$form->addElement('text', 'shortname', get_string('profileshortname', 'admin'), 'maxlength="100" size="25"');
|
||||
$form->addRule('shortname', $strrequired, 'required', null, 'client');
|
||||
$form->setType('shortname', PARAM_ALPHANUM);
|
||||
|
||||
$form->addElement('text', 'name', get_string('profilename', 'admin'), 'size="30"');
|
||||
$form->addElement('text', 'name', get_string('profilename', 'admin'), 'size="50"');
|
||||
$form->addRule('name', $strrequired, 'required', null, 'client');
|
||||
$form->setType('name', PARAM_MULTILANG);
|
||||
|
||||
@ -92,9 +92,12 @@ class profile_define_base {
|
||||
function define_validate_common($data) {
|
||||
$err = array();
|
||||
|
||||
/// Check the shortname was not truncated by cleaning
|
||||
if (empty($data->shortname)) {
|
||||
$err['shortname'] = get_string('required');
|
||||
|
||||
/// Check the shortname is unique
|
||||
if (($field = get_record('user_info_field', 'shortname', $data->shortname)) and ($field->id <> $data->id)) {
|
||||
//if (record_exists_select('user_info_field', 'shortname='.$data->shortname.' AND id<>'.$data->id)) {
|
||||
} else if (($field = get_record('user_info_field', 'shortname', $data->shortname)) and ($field->id <> $data->id)) {
|
||||
$err['shortname'] = get_string('profileshortnamenotunique', 'admin');
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ class profile_define_menu extends profile_define_base {
|
||||
$form->setType('param1', PARAM_MULTILANG);
|
||||
|
||||
/// Default data
|
||||
$form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="30"');
|
||||
$form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
|
||||
$form->setType('defaultdata', PARAM_MULTILANG);
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,17 @@ class profile_define_text extends profile_define_base {
|
||||
|
||||
function define_form_specific(&$form) {
|
||||
/// Default data
|
||||
$form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="30"');
|
||||
$form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
|
||||
$form->setType('defaultdata', PARAM_MULTILANG);
|
||||
|
||||
/// Param 1 for text type is the size of the field
|
||||
$form->addElement('text', 'param1', get_string('profilefieldsize', 'admin'), 'size="6"');
|
||||
$form->setDefault('param1', 50);
|
||||
$form->setType('param1', PARAM_INT);
|
||||
|
||||
/// Param 2 for text type is the maxlength of the field
|
||||
$form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"');
|
||||
$form->setDefault('param2', 100);
|
||||
$form->setType('param2', PARAM_INT);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class profile_field_base {
|
||||
$usernew = $this->save_data_preprocess($usernew);
|
||||
|
||||
if (!isset($usernew->{$this->inputname})) {
|
||||
// field not present in form, probably locked and incisible - skip it!
|
||||
// field not present in form, probably locked and invisible - skip it
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user