diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index e9cf205cd0..1bc0cbfdcf 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -259,7 +259,7 @@ class Form implements \IteratorAggregate, FormInterface throw new AlreadyBoundException('You cannot set the parent of a bound form'); } - if ('' === $this->config->getName()) { + if (null !== $parent && '' === $this->config->getName()) { throw new FormException('A form with an empty name cannot have a parent form.'); } diff --git a/src/Symfony/Component/Form/FormInterface.php b/src/Symfony/Component/Form/FormInterface.php index 2f78d155d9..39f0b1e9a5 100644 --- a/src/Symfony/Component/Form/FormInterface.php +++ b/src/Symfony/Component/Form/FormInterface.php @@ -21,7 +21,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable /** * Sets the parent form. * - * @param FormInterface $parent The parent form + * @param FormInterface|null $parent The parent form or null if it's the root. * * @return FormInterface The form instance */ @@ -30,7 +30,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable /** * Returns the parent form. * - * @return FormInterface The parent form + * @return FormInterface|null The parent form or null if there is none. */ public function getParent();