1 views_handler_filter.inc views_handler_filter::show_build_group_button(&$form, &$form_state)

Shortcut to display the build_group/hide button.

File

core/modules/views/handlers/views_handler_filter.inc, line 363
@todo.

Class

views_handler_filter
Base class for filters.

Code

function show_build_group_button(&$form, &$form_state) {

  $form['group_button'] = array(
    '#prefix' => '<div class="views-grouped clearfix">',
    '#suffix' => '</div>',
    // Should always come after the description and the relationship.
    '#weight' => -190,
  );

  $grouped_description = t('Grouped filters allow a choice between predefined operator|value pairs.');
  $form['group_button']['radios'] = array(
    '#theme_wrappers' => array('container'),
    '#attributes' => array('class' => array('js-show')),
  );
  $form['group_button']['radios']['radios'] = array(
    '#title' => t('Filter type to expose'),
    '#description' => $grouped_description,
    '#type' => 'radios',
    '#options' => array(
      t('Single filter'),
      t('Grouped filters'),
    ),
  );

  if (empty($this->options['is_grouped'])) {
    $form['group_button']['markup'] = array(
      '#markup' => '<div class="description grouped-description">' . $grouped_description . '</div>',
    );
    $form['group_button']['button'] = array(
      '#limit_validation_errors' => array(),
      '#type' => 'submit',
      '#value' => t('Grouped filters'),
      '#submit' => array('views_ui_config_item_form_build_group'),
      '#ajax' => array(
        'path' => empty($form_state['path']) ? current_path() : $form_state['path'],
      ),
    );
    $form['group_button']['radios']['radios']['#default_value'] = 0;
  }
  else {
    $form['group_button']['button'] = array(
      '#limit_validation_errors' => array(),
      '#type' => 'submit',
      '#value' => t('Single filter'),
      '#submit' => array('views_ui_config_item_form_build_group'),
      '#ajax' => array(
        'path' => empty($form_state['path']) ? current_path() : $form_state['path'],
      ),
    );
    $form['group_button']['radios']['radios']['#default_value'] = 1;
  }
}