diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 14d88e3403..5ac205a1d7 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Doctrine\Form\Type; use Doctrine\Common\Persistence\ManagerRegistry; +use Symfony\Component\Form\Exception\FormException; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList; @@ -130,7 +131,17 @@ abstract class DoctrineType extends AbstractType return $registry->getManager($em); } - return $registry->getManagerForClass($options['class']); + $em = $registry->getManagerForClass($options['class']); + + if (null === $em) { + throw new FormException(sprintf( + 'Class "%s" seems not to be a managed Doctrine entity. ' . + 'Did you forget to map it?', + $options['class'] + )); + } + + return $em; }; $resolver->setDefaults(array(