Fixed the parsing of formed defined by creating the FormBuilder directly

This commit is contained in:
Christophe Coevoet 2012-05-23 00:20:03 +02:00
parent 22dc9ae0c0
commit 378f21ec10
5 changed files with 30 additions and 1 deletions

View File

@ -56,7 +56,11 @@ class FormTypeParser
$parameters = array(); $parameters = array();
foreach ($builder->all() as $name => $child) { foreach ($builder->all() as $name => $child) {
$childBuilder = $builder->create($name, $child['type'] ?: 'text', $child['options']); if ($child instanceof FormBuilder) {
$childBuilder = $child;
} else {
$childBuilder = $builder->create($name, $child['type'] ?: 'text', $child['options']);
}
$bestType = ''; $bestType = '';
foreach ($childBuilder->getTypes() as $type) { foreach ($childBuilder->getTypes() as $type) {

View File

@ -23,6 +23,7 @@ class TestType extends AbstractType
{ {
$builder->add('a', null, array('description' => 'A nice description')); $builder->add('a', null, array('description' => 'A nice description'));
$builder->add('b'); $builder->add('b');
$builder->add($builder->create('c', 'checkbox'));
} }
/** /**

View File

@ -24,4 +24,6 @@ class Test
* @Assert\Type("DateTime"); * @Assert\Type("DateTime");
*/ */
public $b; public $b;
public $c;
} }

View File

@ -75,6 +75,11 @@ b:
* type: string * type: string
* required: true * required: true
c:
* type: boolean
* required: true
### `POST` /tests ### ### `POST` /tests ###
@ -93,6 +98,11 @@ b:
* type: string * type: string
* required: true * required: true
c:
* type: boolean
* required: true
# others # # others #

View File

@ -97,6 +97,12 @@ class SimpleFormatterTest extends WebTestCase
'required' => true, 'required' => true,
'description' => '', 'description' => '',
), ),
'c' =>
array(
'dataType' => 'boolean',
'required' => true,
'description' => '',
),
), ),
'description' => 'create test', 'description' => 'create test',
), ),
@ -121,6 +127,12 @@ class SimpleFormatterTest extends WebTestCase
'required' => true, 'required' => true,
'description' => '', 'description' => '',
), ),
'c' =>
array(
'dataType' => 'boolean',
'required' => true,
'description' => '',
),
), ),
'description' => 'create test', 'description' => 'create test',
), ),