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);
} /**
* Entity builder for layout options on the entity view display form.
*/
public function entityFormEntityBuild($entity_type_id, LayoutEntityDisplayInterface
$display, &
$form, FormStateInterface &
$form_state) { $set_enabled =
(bool) $form_state->
getValue(['layout', 'enabled'
], FALSE
);
$already_enabled =
$display->
isLayoutBuilderEnabled();
if ($set_enabled) { $overridable =
(bool) $form_state->
getValue(['layout', 'allow_custom'
], FALSE
);