function ContextualLinks::buildOptionsForm

Same name in other branches
  1. 9 core/modules/contextual/src/Plugin/views/field/ContextualLinks.php \Drupal\contextual\Plugin\views\field\ContextualLinks::buildOptionsForm()
  2. 10 core/modules/contextual/src/Plugin/views/field/ContextualLinks.php \Drupal\contextual\Plugin\views\field\ContextualLinks::buildOptionsForm()
  3. 11.x core/modules/contextual/src/Plugin/views/field/ContextualLinks.php \Drupal\contextual\Plugin\views\field\ContextualLinks::buildOptionsForm()

Overrides FieldPluginBase::buildOptionsForm

File

core/modules/contextual/src/Plugin/views/field/ContextualLinks.php, line 47

Class

ContextualLinks
Provides a handler that adds contextual links.

Namespace

Drupal\contextual\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $all_fields = $this->view->display_handler
        ->getFieldLabels();
    // Offer to include only those fields that follow this one.
    $field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));
    $form['fields'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('Fields'),
        '#description' => $this->t('Fields to be included as contextual links.'),
        '#options' => $field_options,
        '#default_value' => $this->options['fields'],
    ];
    $form['destination'] = [
        '#type' => 'select',
        '#title' => $this->t('Include destination'),
        '#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
        '#options' => [
            '0' => $this->t('No'),
            '1' => $this->t('Yes'),
        ],
        '#default_value' => $this->options['destination'],
    ];
}

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