You are here

protected function LayoutBuilderEntityViewDisplayForm::copyFormValuesToEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::copyFormValuesToEntity()
  2. 9 core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php \Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm::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\Form

Code

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);
}