From 454e83e93621631c2d5569be08e57fee0e9a5912 Mon Sep 17 00:00:00 2001 From: Jeroen Bobbeldijk Date: Fri, 29 Sep 2017 10:06:17 +0200 Subject: [PATCH] Fix entity browser edit form when edit form class is not defined --- src/Controllers/EntityBrowserController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Controllers/EntityBrowserController.php b/src/Controllers/EntityBrowserController.php index aebb4be..c378880 100644 --- a/src/Controllers/EntityBrowserController.php +++ b/src/Controllers/EntityBrowserController.php @@ -29,8 +29,16 @@ class EntityBrowserController extends ControllerBase { * containing the edit form. */ public function entityBrowserEdit(EntityInterface $entity, Request $request) { + + // Use edit form class if it exists, otherwise use default form class. + $operation = 'default'; + $entity_type = $entity->getEntityType(); + if ($entity_type->getFormClass('edit')) { + $operation = 'edit'; + } + // Build the entity edit form. - $form_object = $this->entityTypeManager()->getFormObject($entity->getEntityTypeId(), 'edit'); + $form_object = $this->entityTypeManager()->getFormObject($entity->getEntityTypeId(), $operation); $form_object->setEntity($entity); $form_state = (new FormState()) ->setFormObject($form_object)