diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index d0caa65d0e..42b94ec4f0 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -643,6 +643,16 @@ class FormBuilder return isset($this->children[$name]); } + /** + * Returns the children. + * + * @return array + */ + public function all() + { + return $this->children; + } + /** * Creates the form. * diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index 9860c6bfca..b17aed9e47 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -110,6 +110,22 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->builder->has('foo')); } + public function testAll() + { + $this->assertEquals(0, count($this->builder->all())); + $this->assertFalse($this->builder->has('foo')); + + $this->builder->add('foo', 'text'); + $children = $this->builder->all(); + + $this->assertTrue($this->builder->has('foo')); + $this->assertEquals(1, count($children)); + $this->assertArrayHasKey('foo', $children); + + $foo = $children['foo']; + $this->assertEquals('text', $foo['type']); + } + public function testAddFormType() { $this->assertFalse($this->builder->has('foo'));