public function HierarchicalFormatter::settingsForm in Hierarchical Term Formatter 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/ HierarchicalFormatter.php, line 139
Class
- HierarchicalFormatter
- Plugin implementation of the 'rating' formatter.
Namespace
Drupal\hierarchical_term_formatter\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
$form['display'] = [
'#title' => $this
->t('Terms to display'),
'#description' => $this
->t('Choose what terms to display.'),
'#type' => 'select',
'#options' => $this
->displayOptions(),
'#default_value' => $this
->getSetting('display'),
'#required' => FALSE,
];
$form['link'] = [
'#title' => $this
->t('Link each term'),
'#description' => $this
->t('If checked, the terms will link to their corresponding term pages.'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('link'),
];
$form['reverse'] = [
'#title' => $this
->t('Reverse order'),
'#description' => $this
->t('If checked, children display first, parents last.'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('reverse'),
];
$form['wrap'] = [
'#title' => $this
->t('Wrap each term'),
'#description' => $this
->t('Choose what type of html elements you would like to wrap the terms in, if any.'),
'#type' => 'select',
'#options' => $this
->wrapOptions(),
'#default_value' => $this
->getSetting('wrap'),
'#required' => FALSE,
];
$form['separator'] = [
'#title' => $this
->t('Separator'),
'#description' => $this
->t('Enter some text or markup that will separate each term in the hierarchy. Leave blank for no separator. Example: <em>»</em>'),
'#type' => 'textfield',
'#size' => 20,
'#default_value' => $this
->getSetting('separator'),
'#required' => FALSE,
];
return $form;
}