You are here

public function StringArgument::buildOptionsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides ArgumentPluginBase::buildOptionsForm

1 call to StringArgument::buildOptionsForm()
StringListField::buildOptionsForm in core/modules/options/src/Plugin/views/argument/StringListField.php
Provide a form to edit options for this plugin.
1 method overrides StringArgument::buildOptionsForm()
StringListField::buildOptionsForm in core/modules/options/src/Plugin/views/argument/StringListField.php
Provide a form to edit options for this plugin.

File

core/modules/views/src/Plugin/views/argument/StringArgument.php, line 60
Contains \Drupal\views\Plugin\views\argument\StringArgument.

Class

StringArgument
Basic argument handler to implement string arguments that may have length limits.

Namespace

Drupal\views\Plugin\views\argument

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['glossary'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Glossary mode'),
    '#description' => $this
      ->t('Glossary mode applies a limit to the number of characters used in the filter value, which allows the summary view to act as a glossary.'),
    '#default_value' => $this->options['glossary'],
    '#group' => 'options][more',
  );
  $form['limit'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Character limit'),
    '#description' => $this
      ->t('How many characters of the filter value to filter against. If set to 1, all fields starting with the first letter in the filter value would be matched.'),
    '#default_value' => $this->options['limit'],
    '#states' => array(
      'visible' => array(
        ':input[name="options[glossary]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
    '#group' => 'options][more',
  );
  $form['case'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Case'),
    '#description' => $this
      ->t('When printing the title and summary, how to transform the case of the filter value.'),
    '#options' => array(
      'none' => $this
        ->t('No transform'),
      'upper' => $this
        ->t('Upper case'),
      'lower' => $this
        ->t('Lower case'),
      'ucfirst' => $this
        ->t('Capitalize first letter'),
      'ucwords' => $this
        ->t('Capitalize each word'),
    ),
    '#default_value' => $this->options['case'],
    '#group' => 'options][more',
  );
  $form['path_case'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Case in path'),
    '#description' => $this
      ->t('When printing url paths, how to transform the case of the filter value. Do not use this unless with Postgres as it uses case sensitive comparisons.'),
    '#options' => array(
      'none' => $this
        ->t('No transform'),
      'upper' => $this
        ->t('Upper case'),
      'lower' => $this
        ->t('Lower case'),
      'ucfirst' => $this
        ->t('Capitalize first letter'),
      'ucwords' => $this
        ->t('Capitalize each word'),
    ),
    '#default_value' => $this->options['path_case'],
    '#group' => 'options][more',
  );
  $form['transform_dash'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Transform spaces to dashes in URL'),
    '#default_value' => $this->options['transform_dash'],
    '#group' => 'options][more',
  );
  if (!empty($this->definition['many to one'])) {
    $form['add_table'] = array(
      '#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'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Do not display items with no value in summary'),
      '#default_value' => !empty($this->options['require_value']),
      '#group' => 'options][more',
    );
  }

  // allow + for or, , for and
  $form['break_phrase'] = array(
    '#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',
  );
}