public function SoundCloudLinkFormatter::settingsForm in SoundCloud field 8
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/ SoundCloudLinkFormatter.php, line 40
Class
- SoundCloudLinkFormatter
- Plugin implementation of the 'soundcloud_link' formatter.
Namespace
Drupal\soundcloudfield\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['trim_length'] = array(
'#type' => 'number',
'#title' => $this
->t('Trim link text length'),
'#field_suffix' => $this
->t('characters'),
'#default_value' => $this
->getSetting('trim_length'),
'#min' => 1,
'#description' => $this
->t('Leave blank to allow unlimited link text lengths.'),
);
$elements['rel'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Add rel="nofollow" to links'),
'#return_value' => 'nofollow',
'#default_value' => $this
->getSetting('rel'),
);
$elements['target'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Open link in new window'),
'#return_value' => '_blank',
'#default_value' => $this
->getSetting('target'),
);
return $elements;
}