Check instance of FormBuilderInterface instead of FormBuilder
This commit is contained in:
parent
089d9f734a
commit
44469d01d1
@ -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) {
|
||||
|
@ -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.');
|
||||
|
Reference in New Issue
Block a user