You are here

public function TokenArgument::buildOptionsForm in Views Token Argument 8

Same name and namespace in other branches
  1. 2.0.x 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 41

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'] = array(
    '#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'] = array(
    '#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'] = array(
    '#type' => 'radios',
    '#title' => $this
      ->t('Multiple values handling condition'),
    '#options' => array(
      '+' => $this
        ->t('Or'),
      ',' => $this
        ->t('And'),
    ),
    '#default_value' => $this->options['and_or'],
    '#states' => array(
      'invisible' => array(
        ':input[name="options[argument_default][token][process]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#description' => $this
      ->t('You should authorize multiple values at the bottom of this form.'),
  );
  $form['all_option'] = array(
    '#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'] = array(
    '#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.'),
  );
}