function LinkItem::fieldSettingsForm

Same name and namespace in other branches
  1. 8.9.x core/modules/link/src/Plugin/Field/FieldType/LinkItem.php \Drupal\link\Plugin\Field\FieldType\LinkItem::fieldSettingsForm()
  2. 10 core/modules/link/src/Plugin/Field/FieldType/LinkItem.php \Drupal\link\Plugin\Field\FieldType\LinkItem::fieldSettingsForm()
  3. 11.x core/modules/link/src/Plugin/Field/FieldType/LinkItem.php \Drupal\link\Plugin\Field\FieldType\LinkItem::fieldSettingsForm()

Overrides FieldItemBase::fieldSettingsForm

File

core/modules/link/src/Plugin/Field/FieldType/LinkItem.php, line 88

Class

LinkItem
Plugin implementation of the 'link' field type.

Namespace

Drupal\link\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = [];
  $element['link_type'] = [
    '#type' => 'radios',
    '#title' => $this->t('Allowed link type'),
    '#default_value' => $this->getSetting('link_type'),
    '#options' => [
      static::LINK_INTERNAL => $this->t('Internal links only'),
      static::LINK_EXTERNAL => $this->t('External links only'),
      static::LINK_GENERIC => $this->t('Both internal and external links'),
    ],
  ];
  $element['title'] = [
    '#type' => 'radios',
    '#title' => $this->t('Allow link text'),
    '#default_value' => $this->getSetting('title'),
    '#options' => [
      DRUPAL_DISABLED => $this->t('Disabled'),
      DRUPAL_OPTIONAL => $this->t('Optional'),
      DRUPAL_REQUIRED => $this->t('Required'),
    ],
  ];
  return $element;
}

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