function FieldStorageAddForm::configureEntityFormDisplay
Same name in other branches
- 8.9.x core/modules/field_ui/src/Form/FieldStorageAddForm.php \Drupal\field_ui\Form\FieldStorageAddForm::configureEntityFormDisplay()
Configures the field for the default form mode.
Parameters
string $field_name: The field name.
string|null $widget_id: (optional) The plugin ID of the widget. Defaults to NULL.
array $widget_settings: (optional) An array of widget settings. Defaults to an empty array.
1 call to FieldStorageAddForm::configureEntityFormDisplay()
- FieldStorageAddForm::submitForm in core/
modules/ field_ui/ src/ Form/ FieldStorageAddForm.php - Form submission handler.
File
-
core/
modules/ field_ui/ src/ Form/ FieldStorageAddForm.php, line 450
Class
- FieldStorageAddForm
- Provides a form for the "field storage" add page.
Namespace
Drupal\field_ui\FormCode
protected function configureEntityFormDisplay($field_name, $widget_id = NULL, array $widget_settings = []) {
$options = [];
if ($widget_id) {
$options['type'] = $widget_id;
if (!empty($widget_settings)) {
$options['settings'] = $widget_settings;
}
}
// Make sure the field is displayed in the 'default' form mode (using
// default widget and settings). It stays hidden for other form modes
// until it is explicitly configured.
$this->entityDisplayRepository
->getFormDisplay($this->entityTypeId, $this->bundle, 'default')
->setComponent($field_name, $options)
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.