You are here

function cck_select_other_field_widget_settings_form in CCK Select Other 7.2

Same name and namespace in other branches
  1. 7 cck_select_other.module \cck_select_other_field_widget_settings_form()

Implementation of hook_field_widget_settings_form().

File

./cck_select_other.module, line 72
Implements a select list widget that lets a user provide an alternate option.

Code

function cck_select_other_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'];
  $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' => !empty($settings['select_list_options']) ? $settings['select_list_options'] : 'other|Other',
  );
  $form['select_list_options_fieldset']['advanced_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('PHP code'),
    '#collapsible' => TRUE,
    '#collapsed' => empty($settings['select_list_options_fieldset']['advanced_options']['select_list_options_php']),
  );
  $form['select_list_options_fieldset']['advanced_options']['select_list_options_php'] = array(
    '#type' => 'textarea',
    '#title' => t('Code'),
    '#default_value' => !empty($settings['select_list_options_fieldset']['advanced_options']['select_list_options_php']) ? $settings['select_list_options_fieldset']['advanced_options']['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.'),
  );
  if (!user_access('use PHP for settings')) {
    $form['select_list_options_fieldset']['advanced_options']['select_list_options_php']['#disabled'] = TRUE;
    $form['select_list_options_fieldset']['advanced_options']['select_list_options_php']['#prefix'] = t('You do not have access to write PHP code to generate select list options.');
  }
  return $form;
}