Skip to content

Commit

Permalink
Various changes for GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikawhero committed Jan 12, 2007
1 parent 9ac3326 commit 1f4cd1b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
26 changes: 26 additions & 0 deletions user/profile/field/menu/field.class.php
Expand Up @@ -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;
}
}

?>
17 changes: 16 additions & 1 deletion user/profile/field/text/field.class.php
Expand Up @@ -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.'" ');
Expand All @@ -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.