You are here

public function AdministrativeArea::buildExposeForm in Address 8

Options form subform for exposed filter options.

Overrides InOperator::buildExposeForm

See also

buildOptionsForm()

File

src/Plugin/views/filter/AdministrativeArea.php, line 312

Class

AdministrativeArea
Filter by administrative area.

Namespace

Drupal\address\Plugin\views\filter

Code

public function buildExposeForm(&$form, FormStateInterface $form_state) {
  parent::buildExposeForm($form, $form_state);

  // Only show the label element if we're configured for a static label.
  $form['expose']['label']['#states'] = [
    'visible' => [
      ':input[name="options[expose][label_type]"]' => [
        'value' => 'static',
      ],
    ],
  ];

  // Only show the reduce option if we have a static country. If we're
  // getting values from a filter or argument, there are no fixed values to
  // reduce to.
  $form['expose']['reduce']['#states'] = [
    'visible' => [
      ':input[name="options[country][country_source]"]' => [
        'value' => 'static',
      ],
    ],
  ];

  // Repair the wrapper container on $form['value'] clobbered by
  // FilterPluginBase::buildExposeForm().
  $form['value']['#prefix'] = '<div id="admin-area-value-options-ajax-wrapper" class="views-group-box views-right-60">';
  $form['value']['#suffix'] = '</div>';
  return $form;
}