You are here

function context_field_field_widget_settings_form in Context Field 7

Provide widget level settings.

File

./context_field.module, line 234
Context Field

Code

function context_field_field_widget_settings_form($field, $instance) {
  $settings = $instance['widget']['settings'];
  $form = array();
  switch ($instance['widget']['type']) {
    case 'context_field_select':
    case 'context_field_autocomplete':
      $form['form_element'] = array(
        '#type' => 'fieldset',
        '#title' => t('Widget Settings'),
      );
      $form['form_element']['allow_create'] = array(
        '#type' => 'checkbox',
        '#title' => 'Allow Creation of new Context',
        '#default_value' => !empty($settings['form_element']['allow_create']),
      );
      $form['form_element']['category'] = array(
        '#type' => 'textfield',
        '#title' => 'Category',
        '#default_value' => isset($settings['form_element']['category']) ? $settings['form_element']['category'] : '',
        '#description' => t('The subset of context fields you\'d like to utilize for this instance of context field. For example, a blog category for contexts that belong to a blog, or profile contexts for a profile page.'),
      );
      break;
    case 'context_field':
    case 'context_field_default':
      $form['form_element'] = array(
        '#type' => 'fieldset',
        '#title' => t('Widget Settings'),
      );
      $form['form_element']['user_toggle'] = array(
        '#type' => 'checkbox',
        '#title' => t('Allow User to toggle if there is a context or not'),
        '#default_value' => !empty($settings['form_element']['user_toggle']),
      );
      break;
  }
  return $form;
}