diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index a28a6421c5..347d3f61a0 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -144,7 +144,7 @@ class DateType extends AbstractType $view->setVar('type', 'date'); } - if ($view->hasChildren()) { + if (count($view) > 0) { $pattern = $form->getConfig()->getAttribute('formatter')->getPattern(); // set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php index 292dcb094a..10b9deb793 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php @@ -159,7 +159,7 @@ class FormType extends AbstractType } return function (FormInterface $form) { - if ($form->hasChildren()) { + if (count($form) > 0) { return array(); } diff --git a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php index 3e7aaa196c..c7eb63ada4 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php +++ b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php @@ -66,7 +66,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension $data = $options['csrf_provider']->generateCsrfToken($options['intention']); $csrfForm = $factory->createNamed($options['csrf_field_name'], 'hidden', $data, array( - 'property_path' => false, + 'mapped' => false, )); $view->add($csrfForm->createView($view)); diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 3e99bb4f1a..d4d880de0a 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -588,7 +588,7 @@ class Form implements \IteratorAggregate, FormInterface // Form bound without name $params = $request->request->all(); $files = $request->files->all(); - } elseif ($this->hasChildren()) { + } elseif (count($this->children) > 0) { // Form bound with name and children $params = $request->request->get($name, array()); $files = $request->files->get($name, array()); @@ -757,14 +757,12 @@ class Form implements \IteratorAggregate, FormInterface $errors .= str_repeat(' ', $level).'ERROR: '.$error->getMessage()."\n"; } - if ($this->hasChildren()) { - foreach ($this->children as $key => $child) { - $errors .= str_repeat(' ', $level).$key.":\n"; - if ($err = $child->getErrorsAsString($level + 4)) { - $errors .= $err; - } else { - $errors .= str_repeat(' ', $level + 4)."No errors\n"; - } + foreach ($this->children as $key => $child) { + $errors .= str_repeat(' ', $level).$key.":\n"; + if ($err = $child->getErrorsAsString($level + 4)) { + $errors .= $err; + } else { + $errors .= str_repeat(' ', $level + 4)."No errors\n"; } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index 8953def510..77286d0366 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -535,7 +535,7 @@ class FormTypeTest extends TypeTestCase 'compound' => true, )); - $this->assertTrue($form->getErrorBubbling()); + $this->assertTrue($form->getConfig()->getErrorBubbling()); } public function testNoErrorBubblingIfNotCompound() @@ -544,7 +544,7 @@ class FormTypeTest extends TypeTestCase 'compound' => false, )); - $this->assertFalse($form->getErrorBubbling()); + $this->assertFalse($form->getConfig()->getErrorBubbling()); } public function testOverrideErrorBubbling() @@ -554,7 +554,7 @@ class FormTypeTest extends TypeTestCase 'error_bubbling' => true, )); - $this->assertTrue($form->getErrorBubbling()); + $this->assertTrue($form->getConfig()->getErrorBubbling()); } public function testPropertyPath() diff --git a/src/Symfony/Component/Form/Tests/FormTest.php b/src/Symfony/Component/Form/Tests/FormTest.php index 40f0bb8713..63dc7c5a6b 100644 --- a/src/Symfony/Component/Form/Tests/FormTest.php +++ b/src/Symfony/Component/Form/Tests/FormTest.php @@ -376,7 +376,7 @@ class FormTest extends \PHPUnit_Framework_TestCase $this->form->add($child); $this->assertSame($this->form, $child->getParent()); - $this->assertSame(array('foo' => $child), $this->form->getChildren()); + $this->assertSame(array('foo' => $child), $this->form->all()); } /** @@ -440,7 +440,7 @@ class FormTest extends \PHPUnit_Framework_TestCase $this->form->add($this->getBuilder('foo')->getForm()); $this->form->add($this->getBuilder('bar')->getForm()); - $this->assertSame($this->form->getChildren(), iterator_to_array($this->form)); + $this->assertSame($this->form->all(), iterator_to_array($this->form)); } public function testBound() @@ -1104,7 +1104,7 @@ class FormTest extends \PHPUnit_Framework_TestCase ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type1::buildView'; $test->assertTrue($view->hasParent()); - $test->assertFalse($view->hasChildren()); + $test->assertEquals(0, count($view)); })); $type1Extension->expects($this->once()) @@ -1112,7 +1112,7 @@ class FormTest extends \PHPUnit_Framework_TestCase ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type1ext::buildView'; $test->assertTrue($view->hasParent()); - $test->assertFalse($view->hasChildren()); + $test->assertEquals(0, count($view)); })); $type2->expects($this->once()) @@ -1120,7 +1120,7 @@ class FormTest extends \PHPUnit_Framework_TestCase ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type2::buildView'; $test->assertTrue($view->hasParent()); - $test->assertFalse($view->hasChildren()); + $test->assertEquals(0, count($view)); })); $type2Extension->expects($this->once()) @@ -1128,35 +1128,35 @@ class FormTest extends \PHPUnit_Framework_TestCase ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type2ext::buildView'; $test->assertTrue($view->hasParent()); - $test->assertFalse($view->hasChildren()); + $test->assertEquals(0, count($view)); })); $type1->expects($this->once()) ->method('finishView') ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type1::finishView'; - $test->assertTrue($view->hasChildren()); + $test->assertGreaterThan(0, count($view)); })); $type1Extension->expects($this->once()) ->method('finishView') ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type1ext::finishView'; - $test->assertTrue($view->hasChildren()); + $test->assertGreaterThan(0, count($view)); })); $type2->expects($this->once()) ->method('finishView') ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type2::finishView'; - $test->assertTrue($view->hasChildren()); + $test->assertGreaterThan(0, count($view)); })); $type2Extension->expects($this->once()) ->method('finishView') ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) { $calls[] = 'type2ext::finishView'; - $test->assertTrue($view->hasChildren()); + $test->assertGreaterThan(0, count($view)); })); $form = $this->getBuilder()->setTypes(array($type1, $type2))->getForm();