[Form] Fixed regression: bind(null) was not converted to an empty string anymore
This commit is contained in:
parent
fcb2227ac9
commit
6e4ed9e177
@ -179,9 +179,9 @@ class FormType extends AbstractType
|
|||||||
if ($form->hasChildren()) {
|
if ($form->hasChildren()) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -344,6 +344,22 @@ class FormTypeTest extends TypeTestCase
|
|||||||
$this->assertSame(array('firstName' => 'Bernhard'), $form->getData());
|
$this->assertSame(array('firstName' => 'Bernhard'), $form->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBindWithEmptyDataPassesEmptyStringToTransformerIfNoChildren()
|
||||||
|
{
|
||||||
|
$form = $this->factory->createBuilder('form')
|
||||||
|
->appendClientTransformer(new FixedDataTransformer(array(
|
||||||
|
// required for the initial, internal setData(null)
|
||||||
|
null => 'null',
|
||||||
|
// required to test that bind(null) is converted to ''
|
||||||
|
'empty' => '',
|
||||||
|
)))
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
$form->bind(null);
|
||||||
|
|
||||||
|
$this->assertSame('empty', $form->getData());
|
||||||
|
}
|
||||||
|
|
||||||
public function testBindWithEmptyDataUsesEmptyDataOption()
|
public function testBindWithEmptyDataUsesEmptyDataOption()
|
||||||
{
|
{
|
||||||
$author = new Author();
|
$author = new Author();
|
||||||
|
Reference in New Issue
Block a user