protected function LayoutBuilderEntityViewDisplayForm::copyFormValuesToEntity in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::copyFormValuesToEntity()
- 10 core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::copyFormValuesToEntity()
Copies top-level form values to entity properties.
This should not change existing entity properties that are not being edited by this form.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.
array $form: A nested array of form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides EntityDisplayFormBase::copyFormValuesToEntity
File
- core/
modules/ layout_builder/ src/ Form/ LayoutBuilderEntityViewDisplayForm.php, line 184
Class
- LayoutBuilderEntityViewDisplayForm
- Edit form for the LayoutBuilderEntityViewDisplay entity type.
Namespace
Drupal\layout_builder\FormCode
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
// Do not process field values if Layout Builder is or will be enabled.
$set_enabled = (bool) $form_state
->getValue([
'layout',
'enabled',
], FALSE);
/** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $entity */
$already_enabled = $entity
->isLayoutBuilderEnabled();
if ($already_enabled || $set_enabled) {
$form['#fields'] = [];
$form['#extra'] = [];
}
parent::copyFormValuesToEntity($entity, $form, $form_state);
}