diff --git a/user/profile/field/menu/field.class.php b/user/profile/field/menu/field.class.php index 02a177cb8c7da..ad5df466708f7 100644 --- a/user/profile/field/menu/field.class.php +++ b/user/profile/field/menu/field.class.php @@ -47,6 +47,32 @@ function save_data_preprocess($data) { return $this->options[$data]; } } + + function edit_field_specific(&$form) { + /// Param 1 for menu type contains the options + $form->addElement('textarea', 'param1', get_string('profilemenuoptions')); + $form->setType('param1', PARAM_MULTILANG); + + /// Default data + $form->addElement('text', 'defaultdata', get_string('profiledefaultdata'), 'size="30"'); + $form->setType('defaultdata', PARAM_MULTILANG); + } + + function edit_validate_specific($data) { + $err = array(); + + /// Check that we have at least 2 options + if (($options = explode("\n", $data->param1)) === false) { + $err['param1'] = get_string('profilemenunooptions'); + } elseif (count($options) < 2) { + $err['param1'] = get_string('profilemenuoptions'); + + /// Check the default data exists in the options + } elseif (!empty($data->defaultdata) and !in_array($data->defaultdata, $options)) { + $err['defaultdata'] = get_string('profilemenudefaultnotinoptions'); + } + return $err; + } } ?> diff --git a/user/profile/field/text/field.class.php b/user/profile/field/text/field.class.php index fa2f53406552c..96a5cb78ac0d5 100644 --- a/user/profile/field/text/field.class.php +++ b/user/profile/field/text/field.class.php @@ -7,7 +7,7 @@ function display_field_add(&$form) { $size = (empty($this->field->param1)) ? '30' : $this->field->param1; /// Param 2 for text type is the maxlength of the field - $maxlength = (empty($this->field->param2)) ? '254' : $this->field->param2; + $maxlength = (empty($this->field->param2)) ? '2048' : $this->field->param2; /// Create the form field $form->addElement('text', $this->fieldname, $this->field->name, 'maxlength="'.$maxlength.'" size="'.$size.'" '); @@ -17,6 +17,21 @@ function display_field_add(&$form) { function set_data_type() { $this->datatype = 'text'; } + + function edit_field_specific(&$form) { + /// Default data + $form->addElement('text', 'defaultdata', get_string('profiledefaultdata'), 'size="30"'); + $form->setType('defaultdata', PARAM_MULTILANG); + + /// Param 1 for text type is the size of the field + $form->addElement('text', 'param1', get_string('profilefieldsize'), 'size="6"'); + $form->setType('param1', PARAM_INT); + + /// Param 2 for text type is the maxlength of the field + $form->addElement('text', 'param2', get_string('profilefieldmaxlength'), 'size="6"'); + $form->setType('param2', PARAM_INT); + } + } ?>