[Form] Fixed regression: bind(null) was not converted to an empty string anymore

This commit is contained in:
Bernhard Schussek 2012-04-17 17:29:15 +02:00
parent fcb2227ac9
commit 6e4ed9e177
2 changed files with 18 additions and 2 deletions

View File

@ -179,9 +179,9 @@ class FormType extends AbstractType
if ($form->hasChildren()) {
return array();
}
};
return '';
return '';
};
};
return array(

View File

@ -344,6 +344,22 @@ class FormTypeTest extends TypeTestCase
$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()
{
$author = new Author();