function ManyToOne::buildOptionsForm

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/argument/ManyToOne.php \Drupal\views\Plugin\views\argument\ManyToOne::buildOptionsForm()
  2. 10 core/modules/views/src/Plugin/views/argument/ManyToOne.php \Drupal\views\Plugin\views\argument\ManyToOne::buildOptionsForm()
  3. 11.x core/modules/views/src/Plugin/views/argument/ManyToOne.php \Drupal\views\Plugin\views\argument\ManyToOne::buildOptionsForm()

Overrides ArgumentPluginBase::buildOptionsForm

File

core/modules/views/src/Plugin/views/argument/ManyToOne.php, line 61

Class

ManyToOne
An argument handler for use in fields that have a many to one relationship with the table(s) to the left. This adds a bunch of options that are reasonably common with this type of relationship. Definition terms:

Namespace

Drupal\views\Plugin\views\argument

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    // allow + for or, , for and
    $form['break_phrase'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Allow multiple values'),
        '#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'),
        '#default_value' => !empty($this->options['break_phrase']),
        '#group' => 'options][more',
    ];
    $form['add_table'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Allow multiple filter values to work together'),
        '#description' => $this->t('If selected, multiple instances of this filter can work together, as though multiple values were supplied to the same filter. This setting is not compatible with the "Reduce duplicates" setting.'),
        '#default_value' => !empty($this->options['add_table']),
        '#group' => 'options][more',
    ];
    $form['require_value'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Do not display items with no value in summary'),
        '#default_value' => !empty($this->options['require_value']),
        '#group' => 'options][more',
    ];
    $this->helper
        ->buildOptionsForm($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.