public function EntityReferenceTreeWidget::settingsForm in Entity Reference Tree Widget 2.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldWidget/EntityReferenceTreeWidget.php \Drupal\entity_reference_tree\Plugin\Field\FieldWidget\EntityReferenceTreeWidget::settingsForm()
Returns a form to configure settings for the widget.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. 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 definition for the widget settings.
Overrides EntityReferenceAutocompleteWidget::settingsForm
File
- src/
Plugin/ Field/ FieldWidget/ EntityReferenceTreeWidget.php, line 131
Class
- EntityReferenceTreeWidget
- A entity reference tree widget.
Namespace
Drupal\entity_reference_tree\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = [];
// JsTRee theme.
$element['theme'] = [
'#type' => 'radios',
'#title' => t('JsTree theme'),
'#default_value' => $this
->getSetting('theme'),
'#required' => TRUE,
'#options' => array(
'default' => $this
->t('Default'),
'default-dark' => $this
->t('Default Dark'),
),
];
// Tree dot.
$element['dots'] = [
'#type' => 'radios',
'#title' => t('Dot line'),
'#default_value' => $this
->getSetting('dots'),
'#options' => array(
0 => $this
->t('No'),
1 => $this
->t('Yes'),
),
];
// Button label.
$element['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Button label'),
'#default_value' => $this
->getSetting('label'),
];
$element['dialog_title'] = [
'#type' => 'textfield',
'#title' => $this
->t('Dialog title'),
'#default_value' => $this
->getSetting('dialog_title'),
];
return $element;
}