diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 51fc2cbe9d..be04e66bc3 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -144,7 +144,7 @@ class FormBuilder extends FormConfig implements \IteratorAggregate, FormBuilderI { unset($this->unresolvedChildren[$name]); - if (isset($this->children[$name])) { + if (array_key_exists($name, $this->children)) { if ($this->children[$name] instanceof self) { $this->children[$name]->setParent(null); } diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index 52dcebc46f..42d4317459 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -134,6 +134,15 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->builder->has('foo')); } + // https://github.com/symfony/symfony/pull/4826 + public function testRemoveAndGetForm() + { + $this->builder->add('foo', 'text'); + $this->builder->remove('foo'); + $form = $this->builder->getForm(); + $this->assertInstanceOf('Symfony\Component\Form\Form', $form); + } + public function testCreateNoTypeNo() { $this->factory->expects($this->once())