function EntityFormDisplayEditForm::form
Same name and namespace in other branches
- 11.x core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php \Drupal\field_ui\Form\EntityFormDisplayEditForm::form()
Overrides EntityDisplayFormBase::form
File
-
core/
modules/ field_ui/ src/ Form/ EntityFormDisplayEditForm.php, line 157
Class
- EntityFormDisplayEditForm
- Edit form for the EntityFormDisplay entity type.
Namespace
Drupal\field_ui\FormCode
public function form(array $form, FormStateInterface $form_state) : array {
$form = parent::form($form, $form_state);
// Custom display settings.
if ($this->entity
->getMode() == 'default') {
// Only show the settings if there is at least one custom display mode.
$display_mode_options = $this->getDisplayModeOptions();
// Unset default option.
unset($display_mode_options['default']);
if ($display_mode_options) {
$form['modes'] = [
'#type' => 'details',
'#title' => $this->t('Custom display settings'),
];
// Prepare default values for the 'Custom display settings' checkboxes.
$default = [];
if ($enabled_displays = array_filter($this->getDisplayStatuses())) {
$default = array_keys(array_intersect_key($display_mode_options, $enabled_displays));
}
natcasesort($display_mode_options);
$form['modes']['display_modes_custom'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Use custom display settings for the following @display_context modes', [
'@display_context' => $this->displayContext,
]),
'#options' => $display_mode_options,
'#default_value' => $default,
];
// Provide link to manage display modes.
$form['modes']['display_modes_link'] = $this->getDisplayModesLink();
}
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.