diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 8b5b919413..81c9ad5f6d 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -62,7 +62,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); } - if ($child instanceof self) { + if ($child instanceof FormBuilderInterface) { $this->children[$child->getName()] = $child; // In case an unresolved child with the same name exists @@ -72,7 +72,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB } if (!is_string($child) && !is_int($child)) { - throw new UnexpectedTypeException($child, 'string, integer or Symfony\Component\Form\FormBuilder'); + throw new UnexpectedTypeException($child, 'string, integer or Symfony\Component\Form\FormBuilderInterface'); } if (null !== $type && !is_string($type) && !$type instanceof FormTypeInterface) { diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index da691838c3..8c7b96587d 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -11,7 +11,9 @@ namespace Symfony\Component\Form\Tests; +use Symfony\Component\Form\ButtonBuilder; use Symfony\Component\Form\FormBuilder; +use Symfony\Component\Form\SubmitButtonBuilder; class FormBuilderTest extends \PHPUnit_Framework_TestCase { @@ -154,6 +156,12 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase $this->builder->create('foo'); } + public function testAddButton() + { + $this->builder->add(new ButtonBuilder('reset')); + $this->builder->add(new SubmitButtonBuilder('submit')); + } + public function testGetUnknown() { $this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.');