You are here

public function Cookie::buildOptionsForm in Views Extras (Session/Cookie/Token Support) 8

Same name and namespace in other branches
  1. 2.x src/Plugin/views/argument_default/Cookie.php \Drupal\views_extras\Plugin\views\argument_default\Cookie::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentDefaultPluginBase::buildOptionsForm

File

src/Plugin/views/argument_default/Cookie.php, line 99

Class

Cookie
Default argument plugin to use the raw value from the URL.

Namespace

Drupal\views_extras\Plugin\views\argument_default

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['cookie_key'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Cookie variable key'),
    '#default_value' => $this->options['cookie_key'],
    '#description' => $this
      ->t('Key of Cookie variable, e.g. for $_COOKIE["key"], the key would be "key".'),
  );
  $form['fallback_value'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('If cookie variable is not set, what should be the fallback value.'),
    '#default_value' => $this->options['fallback_value'],
    '#description' => $this
      ->t('You may use user tokens.'),
  );
  if ($this->moduleHandler
    ->moduleExists("token")) {
    $form['token_help'] = array(
      '#type' => 'markup',
      '#token_types' => array(
        'user',
      ),
      '#theme' => 'token_tree_link',
    );
  }
}