public function LanguageSelectWidget::settingsForm in Custom Language field 8
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
File
- src/
Plugin/ Field/ FieldWidget/ LanguageSelectWidget.php, line 36
Class
- LanguageSelectWidget
- Plugin implementation of the 'language_select' widget.
Namespace
Drupal\languagefield\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$settings = $this
->getSettings();
$element = parent::settingsForm($form, $form_state);
$element['format'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Display in widget'),
'#description' => $this
->t('Select the elements you want to show. The elements will be concatenated when showing the field.'),
'#default_value' => $settings['format'],
'#options' => LanguageItem::settingsOptions('widget'),
'#required' => TRUE,
];
return $element;
}