public function CshsFlexibleHierarchyFormatter::settingsForm in Client-side Hierarchical Select 8
Same name and namespace in other branches
- 8.3 src/Plugin/Field/FieldFormatter/CshsFlexibleHierarchyFormatter.php \Drupal\cshs\Plugin\Field\FieldFormatter\CshsFlexibleHierarchyFormatter::settingsForm()
- 8.2 src/Plugin/Field/FieldFormatter/CshsFlexibleHierarchyFormatter.php \Drupal\cshs\Plugin\Field\FieldFormatter\CshsFlexibleHierarchyFormatter::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 CshsFormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ CshsFlexibleHierarchyFormatter.php, line 36
Class
- CshsFlexibleHierarchyFormatter
- Plugin implementation of the "Flexible hierarchy" formatter.
Namespace
Drupal\cshs\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) : array {
$element = parent::settingsForm($form, $form_state);
$element['format'] = [
'#type' => 'textfield',
'#title' => $this
->t('Format'),
'#description' => $this
->t('Specify a format for each field item by using tokens.'),
'#default_value' => $this
->getSetting('format'),
];
$element['clear'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Clear Tokens'),
'#description' => $this
->t('Remove token from final text if no replacement value is generated'),
'#default_value' => $this
->getSetting('clear'),
];
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$element['token_help'] = [
'#type' => 'markup',
'#theme' => 'token_tree_link',
'#token_types' => [
'term',
],
];
}
return $element;
}