public function CshsGroupByRootFormatter::settingsForm in Client-side Hierarchical Select 8.3
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 CshsFormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ CshsGroupByRootFormatter.php, line 116
Class
- CshsGroupByRootFormatter
- Plugin implementation of the "Group by root" formatter.
Namespace
Drupal\cshs\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) : array {
$element = parent::settingsForm($form, $form_state);
$element['sort'] = [
'#type' => 'select',
'#title' => $this
->t('Sorting'),
'#options' => \array_map([
$this,
't',
], static::SORT_OPTIONS),
'#default_value' => $this
->getSetting('sort'),
];
$element['depth'] = [
'#type' => 'number',
'#min' => 0,
'#title' => $this
->t('Depth'),
'#description' => $this
->t('The maximum hierarchy depth. Use 0 to not limit or 1 to display just the root term (or the last if reverse order selected).'),
'#default_value' => $this
->getSetting('depth'),
];
return $element;
}