function FilterPluginBase::showBuildGroupButton
Shortcut to display the build_group/hide button.
Parameters
array $form: An alterable, associative array containing the structure of the form, passed by reference.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to FilterPluginBase::showBuildGroupButton()
- FilterPluginBase::buildOptionsForm in core/modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php 
- Provide the basic form which calls through to subforms.
File
- 
              core/modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php, line 490 
Class
- FilterPluginBase
- Base class for Views filters handler plugins.
Namespace
Drupal\views\Plugin\views\filterCode
protected function showBuildGroupButton(&$form, FormStateInterface $form_state) {
  $form['group_button'] = [
    '#prefix' => '<div class="views-grouped clearfix">',
    '#suffix' => '</div>',
    // Should always come after the description and the relationship.
'#weight' => -190,
  ];
  $grouped_description = $this->t('Grouped filters allow a choice between predefined operator|value pairs.');
  $form['group_button']['radios'] = [
    '#theme_wrappers' => [
      'container',
    ],
    '#attributes' => [
      'class' => [
        'js-only',
      ],
    ],
  ];
  $form['group_button']['radios']['radios'] = [
    '#title' => $this->t('Filter type to expose'),
    '#description' => $grouped_description,
    '#type' => 'radios',
    '#options' => [
      $this->t('Single filter'),
      $this->t('Grouped filters'),
    ],
  ];
  if (empty($this->options['is_grouped'])) {
    $form['group_button']['markup'] = [
      '#markup' => '<div class="description grouped-description">' . $grouped_description . '</div>',
    ];
    $form['group_button']['button'] = [
      '#limit_validation_errors' => [],
      '#type' => 'submit',
      '#value' => $this->t('Grouped filters'),
      '#submit' => [
        [
          $this,
          'buildGroupForm',
        ],
      ],
    ];
    $form['group_button']['radios']['radios']['#default_value'] = 0;
  }
  else {
    $form['group_button']['button'] = [
      '#limit_validation_errors' => [],
      '#type' => 'submit',
      '#value' => $this->t('Single filter'),
      '#submit' => [
        [
          $this,
          'buildGroupForm',
        ],
      ],
    ];
    $form['group_button']['radios']['radios']['#default_value'] = 1;
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
