function StringArgument::buildOptionsForm

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::buildOptionsForm()
  2. 8.9.x core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::buildOptionsForm()
  3. 10 core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::buildOptionsForm()

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 64

Class

StringArgument
Argument handler for string.

Namespace

Drupal\views\Plugin\views\argument

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $form['glossary'] = [
        '#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'] = [
        '#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' => [
            'visible' => [
                ':input[name="options[glossary]"]' => [
                    'checked' => TRUE,
                ],
            ],
        ],
        '#group' => 'options][more',
    ];
    $form['case'] = [
        '#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' => [
            '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'] = [
        '#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' => [
            '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'] = [
        '#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'] = [
            '#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'] = [
            '#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". Allow ',' for "and".
    $form['break_phrase'] = [
        '#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',
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.