Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContextualLinks.php

function 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'],
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal