3 class profile_define_menu
extends profile_define_base
{
5 function define_form_specific(&$form) {
6 /// Param 1 for menu type contains the options
7 $form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40));
8 $form->setType('param1', PARAM_MULTILANG
);
11 $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
12 $form->setType('defaultdata', PARAM_MULTILANG
);
15 function define_validate_specific($data) {
18 $data->param1
= str_replace("\r", '', $data->param1
);
20 /// Check that we have at least 2 options
21 if (($options = explode("\n", $data->param1
)) === false) {
22 $err['param1'] = get_string('profilemenunooptions', 'admin');
23 } elseif (count($options) < 2) {
24 $err['param1'] = get_string('profilemenutoofewoptions', 'admin');
26 /// Check the default data exists in the options
27 } elseif (!empty($data->defaultdata
) and !in_array($data->defaultdata
, $options)) {
28 $err['defaultdata'] = get_string('profilemenudefaultnotinoptions', 'admin');
33 function define_save_preprocess($data) {
34 $data->param1
= str_replace("\r", '', $data->param1
);