function LinkFormatter::settingsForm
Same name and namespace in other branches
- 9 core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter::settingsForm()
- 10 core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter::settingsForm()
- 11.x core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter::settingsForm()
Overrides FormatterBase::settingsForm
File
-
core/
modules/ link/ src/ Plugin/ Field/ FieldFormatter/ LinkFormatter.php, line 93
Class
- LinkFormatter
- Plugin implementation of the 'link' formatter.
Namespace
Drupal\link\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['trim_length'] = [
'#type' => 'number',
'#title' => t('Trim link text length'),
'#field_suffix' => t('characters'),
'#default_value' => $this->getSetting('trim_length'),
'#min' => 1,
'#description' => t('Leave blank to allow unlimited link text lengths.'),
];
$elements['url_only'] = [
'#type' => 'checkbox',
'#title' => t('URL only'),
'#default_value' => $this->getSetting('url_only'),
'#access' => $this->getPluginId() == 'link',
];
$elements['url_plain'] = [
'#type' => 'checkbox',
'#title' => t('Show URL as plain text'),
'#default_value' => $this->getSetting('url_plain'),
'#access' => $this->getPluginId() == 'link',
'#states' => [
'visible' => [
':input[name*="url_only"]' => [
'checked' => TRUE,
],
],
],
];
$elements['rel'] = [
'#type' => 'checkbox',
'#title' => t('Add rel="nofollow" to links'),
'#return_value' => 'nofollow',
'#default_value' => $this->getSetting('rel'),
];
$elements['target'] = [
'#type' => 'checkbox',
'#title' => t('Open link in new window'),
'#return_value' => '_blank',
'#default_value' => $this->getSetting('target'),
];
return $elements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.