You are here

function views_handler_filter_countries_list::extra_options_form in Countries 7.2

Same name and namespace in other branches
  1. 8 views/views_handler_filter_countries_list.inc \views_handler_filter_countries_list::extra_options_form()

Provide a form for setting options.

Overrides views_handler::extra_options_form

File

views/views_handler_filter_countries_list.inc, line 26
Views module filter handler class.

Class

views_handler_filter_countries_list
Filter by ISO Code 2.

Code

function extra_options_form(&$form, &$form_state) {
  $form['configuration'] = array(
    '#type' => 'radios',
    '#title' => t('Widget configuration'),
    '#required' => TRUE,
    '#options' => array(
      COUNTRIES_VIEWS_WIDGET_FIELD => t('Field based configuration'),
      COUNTRIES_VIEWS_WIDGET_CUSTOM => t('Custom'),
    ),
    '#default_value' => $this->options['configuration'],
  );
  $form['filter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Custom settings'),
    '#states' => array(
      // Only show field when widget equals "custom"
      'visible' => array(
        ':input[name="options[configuration]"]' => array(
          'value' => COUNTRIES_VIEWS_WIDGET_CUSTOM,
        ),
      ),
    ),
  );
  $form['filter']['enabled'] = array(
    '#type' => 'radios',
    '#title' => t('Country status'),
    '#required' => TRUE,
    '#states' => array(
      // Only show field when widget equals "custom"
      'visible' => array(
        ':input[name="options[configuration]"]' => array(
          'value' => COUNTRIES_VIEWS_WIDGET_CUSTOM,
        ),
      ),
    ),
    '#options' => array(
      COUNTRIES_ENABLED => t('Enabled countries only'),
      COUNTRIES_DISABLED => t('Disabled countries only'),
      COUNTRIES_ALL => t('Both'),
    ),
    '#default_value' => $this->options['filter']['enabled'],
  );
  $form['filter']['continents'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Filter by continent'),
    '#description' => t('If no continents are selected, this filter will not be used.'),
    '#states' => array(
      // Only show field when widget equals "custom"
      'visible' => array(
        ':input[name="options[configuration]"]' => array(
          'value' => COUNTRIES_VIEWS_WIDGET_CUSTOM,
        ),
      ),
    ),
    '#options' => countries_get_continents(),
    '#element_validate' => array(
      '_countries_checkbox_filter',
    ),
    '#default_value' => $this->options['filter']['continents'],
  );
}