Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9582221

Browse files
committed
[Form] ResizeFormListener::preBind() now handles empty strings. Fixes #40
1 parent d0c5727 commit 9582221

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/Form/EventListener/ResizeFormListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function preBind(DataEvent $event)
9494
$form = $event->getForm();
9595
$data = $event->getData();
9696

97-
if (null === $data) {
97+
if (null === $data || '' === $data) {
9898
$data = array();
9999
}
100100

tests/Symfony/Tests/Component/Form/EventListener/ResizeFormListenerTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ public function testPreBindDealsWithNullData()
183183
$this->assertFalse($this->form->has('1'));
184184
}
185185

186+
// fixes https://github.com/symfony/symfony/pull/40
187+
public function testPreBindDealsWithEmptyData()
188+
{
189+
$this->form->add($this->getForm('1'));
190+
191+
$data = '';
192+
$event = new DataEvent($this->form, $data);
193+
$listener = new ResizeFormListener($this->factory, 'text', true);
194+
$listener->preBind($event);
195+
196+
$this->assertFalse($this->form->has('1'));
197+
}
198+
186199
public function testOnBindNormDataRemovesEntriesMissingInTheFormIfResizable()
187200
{
188201
$this->form->add($this->getForm('1'));

0 commit comments

Comments
 (0)