Permalink
Browse files

Various changes for GUI.

  • Loading branch information...
1 parent 9ac3326 commit 1f4cd1bef5c967603510a1dc4ac7379abd18e0bc ikawhero committed Jan 12, 2007
Showing with 42 additions and 1 deletion.
  1. +26 −0 user/profile/field/menu/field.class.php
  2. +16 −1 user/profile/field/text/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;
+ }
}
?>
@@ -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);
+ }
+
}
?>

0 comments on commit 1f4cd1b

Please sign in to comment.