Commit 56a19a6b authored by Attila Santo-Rieder's avatar Attila Santo-Rieder Committed by Joachim Noreiko
Browse files

Issue #3281740 by attisan: Fixed crash on entity tab showing custom form mode.

parent 175af191
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -120,7 +120,18 @@ class EntityForm extends EntityTabContentBase implements ContainerFactoryPluginI
   * {@inheritdoc}
   */
  public function buildContent(EntityInterface $target_entity) {
    return $this->entityFormBuilder->getForm($target_entity, $this->configuration['form_mode']);
    $entity_type = $target_entity->getEntityType();
    $operation = $this->configuration['form_mode'];

    if ($entity_type->getFormClass($operation) === NULL) {
      // Hotpatch in the default handler for the given form mode as a workaround
      // for a core bug.
      // @see https://www.drupal.org/project/drupal/issues/2530086.
      // @todo: remove once the core issue is fixed.
      $entity_type->setFormClass($operation, $entity_type->getFormClass('default'));
    }

    return $this->entityFormBuilder->getForm($target_entity, $operation);
  }

}