diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 6412f94..53f1de3 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -119,6 +119,20 @@ protected function init(array &$form_state) { // module-provided form handlers there. $form_state['controller'] = $this; $this->prepareEntity(); + + // @todo Allow the usage of different form modes by exposing a hook and the + // UI for them. + $form_display = entity_get_render_form_display($this->entity, 'default'); + + // Let modules alter the form display. + $form_display_context = array( + 'entity_type' => $this->entity->entityType(), + 'bundle' => $this->entity->bundle(), + 'form_mode' => 'default', + ); + \Drupal::moduleHandler()->alter('entity_form_display', $form_display, $form_display_context); + + $this->setFormDisplay($form_display, $form_state); } /** @@ -415,19 +429,7 @@ public function getFormDisplay(array $form_state) { */ public function setFormDisplay(EntityFormDisplayInterface $form_display, array &$form_state) { $form_state['form_display'] = $form_display; - } - - /** - * {@inheritdoc} - */ - protected function prepareFormDisplay(EntityFormDisplayInterface $form_display, EntityInterface $entity, $form_mode) { - // Let modules alter the form display. - $form_display_context = array( - 'entity_type' => $entity->entityType(), - 'bundle' => $entity->bundle(), - 'form_mode' => $form_mode, - ); - \Drupal::moduleHandler()->alter('entity_form_display', $form_display, $form_display_context); + return $this; } /**