Skip to content

Commit e8094f4

Browse files
committed
Merge branch '2.3' into 2.5
* 2.3: [PropertyAccessor] Added test to allow null value for a array [Yaml] Fixed #10597: Improved Yaml directive parsing [Form] Set a child type to text if added to the form without a type. Conflicts: src/Symfony/Component/PropertyAccess/PropertyAccessor.php src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
2 parents 7e4d6ff + 30f65c7 commit e8094f4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Form.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,10 @@ public function add($child, $type = null, array $options = array())
888888
// Never initialize child forms automatically
889889
$options['auto_initialize'] = false;
890890

891+
if (null === $type && null === $this->config->getDataClass()) {
892+
$type = 'text';
893+
}
894+
891895
if (null === $type) {
892896
$child = $this->config->getFormFactory()->createForProperty($this->config->getDataClass(), $child, null, $options);
893897
} else {

Tests/CompoundFormTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,22 @@ public function testAddUsingIntegerNameAndType()
205205
$this->assertSame(array(0 => $child), $this->form->all());
206206
}
207207

208+
public function testAddWithoutType()
209+
{
210+
$child = $this->getBuilder('foo')->getForm();
211+
212+
$this->factory->expects($this->once())
213+
->method('createNamed')
214+
->with('foo', 'text')
215+
->will($this->returnValue($child));
216+
217+
$this->form->add('foo');
218+
219+
$this->assertTrue($this->form->has('foo'));
220+
$this->assertSame($this->form, $child->getParent());
221+
$this->assertSame(array('foo' => $child), $this->form->all());
222+
}
223+
208224
public function testAddUsingNameButNoType()
209225
{
210226
$this->form = $this->getBuilder('name', null, '\stdClass')

0 commit comments

Comments
 (0)