You are here

protected function CountryItem::valueForm in Country 8

Options form subform for setting options.

This should be overridden by all child classes and it must define $form['value']

Overrides ManyToOne::valueForm

See also

buildOptionsForm()

File

src/Plugin/views/filter/CountryItem.php, line 130

Class

CountryItem
Filter by country ISO2.

Namespace

Drupal\country\Plugin\views\filter

Code

protected function valueForm(&$form, FormStateInterface $form_state) {
  parent::valueForm($form, $form_state);

  // Take special care when the type is textfield (autocomplete).
  if ($this->options['type'] == 'textfield') {
    $form['value'] = [
      '#title' => $this
        ->t('Some title'),
      '#type' => 'textfield',
      '#autocomplete_route_name' => 'country.autocomplete',
      '#autocomplete_route_parameters' => [
        'entity_type' => $this->definition['entity_type'],
        'bundle' => $this->options['country_target_bundle'],
        'field_name' => $this->definition['field_name'],
      ],
      '#tags' => TRUE,
      '#process_default_value' => FALSE,
    ];
  }
}