Tests and fix for issue in array model data in EntityType field with multiple=true
This commit is contained in:
parent
2e286f8854
commit
aaba6b4c2b
|
@ -1482,4 +1482,38 @@ class EntityTypeTest extends BaseTypeTest
|
|||
$this->assertEquals($collection, $form->getNormData());
|
||||
$this->assertSame(array(), $form->getViewData(), 'View data is always an array');
|
||||
}
|
||||
|
||||
public function testSetDataEmptyArraySubmitNullMultiple()
|
||||
{
|
||||
$emptyArray = array();
|
||||
$form = $this->factory->create(static::TESTED_TYPE, null, array(
|
||||
'em' => 'default',
|
||||
'class' => self::SINGLE_IDENT_CLASS,
|
||||
'multiple' => true,
|
||||
));
|
||||
$form->setData($emptyArray);
|
||||
$form->submit(null);
|
||||
$this->assertInternalType('array', $form->getData());
|
||||
$this->assertEquals(array(), $form->getData());
|
||||
$this->assertEquals(array(), $form->getNormData());
|
||||
$this->assertSame(array(), $form->getViewData(), 'View data is always an array');
|
||||
}
|
||||
|
||||
public function testSetDataNonEmptyArraySubmitNullMultiple()
|
||||
{
|
||||
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
||||
$this->persist(array($entity1));
|
||||
$form = $this->factory->create(static::TESTED_TYPE, null, array(
|
||||
'em' => 'default',
|
||||
'class' => self::SINGLE_IDENT_CLASS,
|
||||
'multiple' => true,
|
||||
));
|
||||
$existing = array(0 => $entity1);
|
||||
$form->setData($existing);
|
||||
$form->submit(null);
|
||||
$this->assertInternalType('array', $form->getData());
|
||||
$this->assertEquals(array(), $form->getData());
|
||||
$this->assertEquals(array(), $form->getNormData());
|
||||
$this->assertSame(array(), $form->getViewData(), 'View data is always an array');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"require-dev": {
|
||||
"symfony/stopwatch": "~2.2",
|
||||
"symfony/dependency-injection": "~2.2",
|
||||
"symfony/form": "~2.7.25|^2.8.18",
|
||||
"symfony/form": "~2.7.34|^2.8.27",
|
||||
"symfony/http-kernel": "~2.2",
|
||||
"symfony/property-access": "~2.3",
|
||||
"symfony/security": "~2.2",
|
||||
|
|
|
@ -80,7 +80,7 @@ class MergeCollectionListener implements EventSubscriberInterface
|
|||
return;
|
||||
}
|
||||
|
||||
if (!$dataToMergeInto) {
|
||||
if (null === $dataToMergeInto) {
|
||||
// No original data was set. Set it if allowed
|
||||
if ($this->allowAdd) {
|
||||
$dataToMergeInto = $data;
|
||||
|
|
Reference in New Issue