public function ForwardLinkFormatter::settingsForm in Forward 4.0.x
Same name and namespace in other branches
- 4.x src/Plugin/Field/FieldFormatter/ForwardLinkFormatter.php \Drupal\forward\Plugin\Field\FieldFormatter\ForwardLinkFormatter::settingsForm()
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides FormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ ForwardLinkFormatter.php, line 107
Class
- ForwardLinkFormatter
- Plugin implementation of the Forward Link formatter.
Namespace
Drupal\forward\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = [];
$settings = $this
->getSettings();
$element['title'] = [
'#type' => 'textfield',
'#title' => $this
->t('Title'),
'#default_value' => $settings['title'],
'#description' => $this
->t('Set the text of the Forward link title. Replacement tokens may be used.'),
'#required' => TRUE,
];
$element['style'] = [
'#type' => 'radios',
'#title' => $this
->t('Style'),
'#default_value' => $settings['style'],
'#options' => [
0 => $this
->t('Text only'),
1 => $this
->t('Icon only'),
2 => $this
->t('Icon and text'),
],
'#description' => $this
->t('Select the visual style of the link.'),
];
$element['icon'] = [
'#type' => 'textfield',
'#title' => $this
->t('Path to custom icon'),
'#default_value' => $settings['icon'],
'#description' => $this
->t('The path to your custom link icon instead of the default icon. Example: sites/default/files/icon.png'),
'#element_validate' => [
[
get_class($this),
'validateIconPath',
],
],
];
$element['nofollow'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Add a nofollow tag to the Forward link'),
'#default_value' => $settings['nofollow'],
];
return $element;
}