You are here

public function TokenArgument::buildOptionsForm in Views Token Argument 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/views/argument_default/TokenArgument.php \Drupal\views_argument_token\Plugin\views\argument_default\TokenArgument::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentDefaultPluginBase::buildOptionsForm

File

src/Plugin/views/argument_default/TokenArgument.php, line 79

Class

TokenArgument
The Token argument default handler.

Namespace

Drupal\views_argument_token\Plugin\views\argument_default

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $form['argument'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Token'),
    '#default_value' => $this->options['argument'],
  ];
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $form['token'] = \Drupal::service('views_argument_token.token')
      ->tokenBrowser();
  }
  $form['process'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Get fields raw values'),
    '#description' => $this
      ->t('Get raw values of fields (only fields are supported).<br/>For example, get ID instead of title for entity reference fields.'),
    '#default_value' => $this->options['process'],
  ];

  // @todo : allow to choose and / or for any multiple value.
  $form['and_or'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Multiple values handling condition'),
    '#options' => [
      '+' => $this
        ->t('Or'),
      ',' => $this
        ->t('And'),
    ],
    '#default_value' => $this->options['and_or'],
    '#states' => [
      'invisible' => [
        ':input[name="options[argument_default][token][process]"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
    '#description' => $this
      ->t('You should authorize multiple values at the bottom of this form.'),
  ];
  $form['all_option'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Send "all" if no value'),
    '#default_value' => $this->options['all_option'],
    '#description' => $this
      ->t('You should enable the "all" argument below.'),
  ];
  $form['debug'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show debug'),
    '#default_value' => $this->options['debug'],
    '#description' => $this
      ->t('Show as a message the argument value for debugging purposes.'),
  ];
}