protected function FilterPluginBase::showBuildGroupButton

Shortcut to display the build_group/hide button.

1 call to FilterPluginBase::showBuildGroupButton()
FilterPluginBase::buildOptionsForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php
Provide the basic form which calls through to subforms. If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php, line 369
Definition of Drupal\views\Plugin\views\filter\FilterPluginBase.

Class

FilterPluginBase
Base class for filters.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function showBuildGroupButton(&$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-only',
      ),
    ),
  );
  $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(
        array(
          $this,
          'buildGroupForm',
        ),
      ),
    );
    $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(
        array(
          $this,
          'buildGroupForm',
        ),
      ),
    );
    $form['group_button']['radios']['radios']['#default_value'] = 1;
  }
}