function LinkItem::fieldSettingsForm

Same name in other branches
  1. 9 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 87

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' => t('Allowed link type'),
        '#default_value' => $this->getSetting('link_type'),
        '#options' => [
            static::LINK_INTERNAL => t('Internal links only'),
            static::LINK_EXTERNAL => t('External links only'),
            static::LINK_GENERIC => t('Both internal and external links'),
        ],
    ];
    $element['title'] = [
        '#type' => 'radios',
        '#title' => t('Allow link text'),
        '#default_value' => $this->getSetting('title'),
        '#options' => [
            DRUPAL_DISABLED => t('Disabled'),
            DRUPAL_OPTIONAL => t('Optional'),
            DRUPAL_REQUIRED => t('Required'),
        ],
    ];
    return $element;
}

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