function EntityLink::buildOptionsForm

Same name in this branch
  1. 11.x core/modules/comment/src/Plugin/views/field/EntityLink.php \Drupal\comment\Plugin\views\field\EntityLink::buildOptionsForm()
Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/EntityLink.php \Drupal\views\Plugin\views\field\EntityLink::buildOptionsForm()
  2. 9 core/modules/comment/src/Plugin/views/field/EntityLink.php \Drupal\comment\Plugin\views\field\EntityLink::buildOptionsForm()
  3. 8.9.x core/modules/views/src/Plugin/views/field/EntityLink.php \Drupal\views\Plugin\views\field\EntityLink::buildOptionsForm()
  4. 8.9.x core/modules/comment/src/Plugin/views/field/EntityLink.php \Drupal\comment\Plugin\views\field\EntityLink::buildOptionsForm()
  5. 10 core/modules/views/src/Plugin/views/field/EntityLink.php \Drupal\views\Plugin\views\field\EntityLink::buildOptionsForm()
  6. 10 core/modules/comment/src/Plugin/views/field/EntityLink.php \Drupal\comment\Plugin\views\field\EntityLink::buildOptionsForm()

Overrides LinkBase::buildOptionsForm

File

core/modules/views/src/Plugin/views/field/EntityLink.php, line 80

Class

EntityLink
Field handler to present a link to an entity.

Namespace

Drupal\views\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $form['output_url_as_text'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Output the URL as text'),
        '#default_value' => $this->options['output_url_as_text'],
    ];
    $form['absolute'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Use absolute link (begins with "http://")'),
        '#default_value' => $this->options['absolute'],
        '#description' => $this->t('Enable this option to output an absolute link. Required if you want to use the path as a link destination.'),
    ];
    parent::buildOptionsForm($form, $form_state);
    // Only show the 'text' field if we don't want to output the raw URL.
    $form['text']['#states']['visible'][':input[name="options[output_url_as_text]"]'] = [
        'checked' => FALSE,
    ];
}

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