Skip to content

Commit 9e1246e

Browse files
committed
Merge branch '2.5' into 2.6
* 2.5: [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.
2 parents d16278f + ac9f753 commit 9e1246e

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
@@ -894,6 +894,10 @@ public function add($child, $type = null, array $options = array())
894894
// Never initialize child forms automatically
895895
$options['auto_initialize'] = false;
896896

897+
if (null === $type && null === $this->config->getDataClass()) {
898+
$type = 'text';
899+
}
900+
897901
if (null === $type) {
898902
$child = $this->config->getFormFactory()->createForProperty($this->config->getDataClass(), $child, null, $options);
899903
} 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)