[Form] Remove usages of deprecated features
This commit is contained in:
parent
ee803cd948
commit
3d800afec3
|
@ -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)
|
||||
|
|
|
@ -159,7 +159,7 @@ class FormType extends AbstractType
|
|||
}
|
||||
|
||||
return function (FormInterface $form) {
|
||||
if ($form->hasChildren()) {
|
||||
if (count($form) > 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
Reference in New Issue