public function OptionsShsWidget::settingsForm in Simple hierarchical select 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Field/FieldWidget/OptionsShsWidget.php \Drupal\shs\Plugin\Field\FieldWidget\OptionsShsWidget::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 WidgetBase::settingsForm
1 call to OptionsShsWidget::settingsForm()
- OptionsShsChosenWidget::settingsForm in modules/
shs_chosen/ src/ Plugin/ Field/ FieldWidget/ OptionsShsChosenWidget.php - Returns a form to configure settings for the widget.
1 method overrides OptionsShsWidget::settingsForm()
- OptionsShsChosenWidget::settingsForm in modules/
shs_chosen/ src/ Plugin/ Field/ FieldWidget/ OptionsShsChosenWidget.php - Returns a form to configure settings for the widget.
File
- src/
Plugin/ Field/ FieldWidget/ OptionsShsWidget.php, line 86
Class
- OptionsShsWidget
- Plugin implementation of the 'options_shs' widget.
Namespace
Drupal\shs\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$field_name = $this->fieldDefinition
->getName();
$element['create_new_items'] = [
'#type' => 'checkbox',
'#title' => t('Allow creating new items'),
'#default_value' => $this
->getSetting('create_new_items'),
'#description' => t('Allow users to create new items of the source bundle.'),
'#disabled' => TRUE,
];
$element['create_new_levels'] = [
'#type' => 'checkbox',
'#title' => t('Allow creating new levels'),
'#default_value' => $this
->getSetting('create_new_levels'),
'#description' => t('Allow users to create new children for items which do not have any children yet.'),
'#states' => [
'visible' => [
':input[name="fields[' . $field_name . '][settings_edit_form][settings][create_new_items]"]' => [
'checked' => TRUE,
],
],
],
'#disabled' => TRUE,
];
$element['force_deepest'] = [
'#type' => 'checkbox',
'#title' => t('Force selection of deepest level'),
'#default_value' => $this
->getSetting('force_deepest'),
'#description' => t('Force users to select terms from the deepest level.'),
];
return $element;
}