Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\FieldInstanceEditForm to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
array $form: The form where the settings form is being included in.
array $form_state: An associative array containing the current state of the form.
array The form elements for the formatter settings.
Overrides FormatterBase::settingsForm
public function settingsForm(array $form, array &$form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['trim_length'] = array(
'#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'] = array(
'#type' => 'checkbox',
'#title' => t('URL only'),
'#default_value' => $this
->getSetting('url_only'),
'#access' => $this
->getPluginId() == 'link',
);
$elements['url_plain'] = array(
'#type' => 'checkbox',
'#title' => t('Show URL as plain text'),
'#default_value' => $this
->getSetting('url_plain'),
'#access' => $this
->getPluginId() == 'link',
'#states' => array(
'visible' => array(
':input[name*="url_only"]' => array(
'checked' => TRUE,
),
),
),
);
$elements['rel'] = array(
'#type' => 'checkbox',
'#title' => t('Add rel="nofollow" to links'),
'#return_value' => 'nofollow',
'#default_value' => $this
->getSetting('rel'),
);
$elements['target'] = array(
'#type' => 'checkbox',
'#title' => t('Open link in new window'),
'#return_value' => '_blank',
'#default_value' => $this
->getSetting('target'),
);
return $elements;
}