You are here

public function SimilarTermsArgument::buildOptionsForm in Similar By Terms 8

Build options settings form.

Overrides NumericArgument::buildOptionsForm

File

src/Plugin/views/argument/SimilarTermsArgument.php, line 78

Class

SimilarTermsArgument
Argument handler to accept a node id.

Namespace

Drupal\similarterms\Plugin\views\argument

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $vocabularies = [];
  $result = $this->vocabularyStorage
    ->loadMultiple();
  foreach ($result as $vocabulary) {
    $vocabularies[$vocabulary
      ->id()] = $vocabulary
      ->label();
  }
  $form['vocabularies'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Limit similarity to terms within these vocabularies'),
    '#description' => $this
      ->t('Choosing any vocabularies here will limit the terms used to calculate similarity. It is usually best NOT to limit the terms, but in some cases this is necessary. Leave all checkboxes unselected to not limit terms.'),
    '#options' => $vocabularies,
    '#default_value' => empty($this->options['vocabularies']) ? [] : $this->options['vocabularies'],
  ];
  $form['include_args'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include argument node(s) in results'),
    '#description' => $this
      ->t('If selected, the node(s) passed as the argument will be included in the view results.'),
    '#default_value' => !empty($this->options['include_args']),
  ];
}