function cck_select_other_widget_settings in CCK Select Other 6
Implementation of hook_widget_settings
File
- ./
cck_select_other.module, line 29 - Implements a select list widget that lets a user provide an alternate option.
Code
function cck_select_other_widget_settings($op, $widget) {
switch ($op) {
case 'form':
$form['select_list_options'] = array(
'#type' => 'textarea',
'#title' => t('Select list options'),
'#description' => t('CCK Select Other uses a separate text area to generate options. You may also put restricted values in the Allowed Values text area.'),
'#default_value' => $widget['select_list_options'],
);
$form['select_list_options_fieldset']['advanced_options'] = array(
'#type' => 'fieldset',
'#title' => t('PHP code'),
'#collapsible' => TRUE,
'#collapsed' => empty($widget['select_list_options_php']),
);
if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
$form['select_list_options_fieldset']['advanced_options']['select_list_options_php'] = array(
'#type' => 'textarea',
'#title' => t('Code'),
'#default_value' => !empty($widget['select_list_options_php']) ? $widget['select_list_options_php'] : '',
'#rows' => 6,
'#description' => t('Advanced usage only: PHP code that returns a keyed array of proposed select list options. Should not include <?php ?> delimiters. If this field is filled out, the array returned by this code will override the proposed select list options above.'),
);
}
else {
$form['select_list_options_fieldset']['advanced_options']['markup_select_list_options_php'] = array(
'#type' => 'item',
'#title' => t('Code'),
'#value' => !empty($widget['select_list_options_php']) ? '<code>' . check_plain($widget['select_list_options_php']) . '</code>' : t('<none>'),
'#description' => empty($widget['select_list_options_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
);
}
return $form;
break;
case 'save':
return array(
'select_list_options',
'select_list_options_php',
);
break;
}
}