8000 [Form] Fixed handling of empty values in checkbox/radio/choice type by webmozart · Pull Request #3859 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Fixed handling of empty values in checkbox/radio/choice type #3859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 10, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Form] Fixed behavior of expanded multiple-choice field when submitte…
…d without ticks
  • Loading branch information
webmozart committed Apr 10, 2012
commit bc9bc4af5df7f4c3eac6c8de9279de8455d08072
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function onBindClientData(FilterDataEvent $event)
$values = (array) $event->getData();
$indices = $this->choiceList->getIndicesForValues($values);

$event->setData(array_combine($indices, $values));
$event->setData(count($indices) > 0 ? array_combine($indices, $values) : array());
}

static public function getSubscribedEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,29 @@ public function testBindMultipleExpanded()
$this->assertNull($form[4]->getClientData());
}

public function testBindMultipleExpandedEmpty()
{
$form = $this->factory->create('choice', null, array(
'multiple' => true,
'expanded' => true,
'choices' => $this->choices,
));

$form->bind(array());

$this->assertSame(array(), $form->getData());
$this->assertFalse($form[0]->getData());
$this->assertFalse($form[1]->getData());
$this->assertFalse($form[2]->getData());
$this->assertFalse($form[3]->getData());
$this->assertFalse($form[4]->getData());
$this->assertNull($form[0]->getClientData());
$this->assertNull($form[1]->getClientData());
$this->assertNull($form[2]->getClientData());
$this->assertNull($form[3]->getClientData());
$this->assertNull($form[4]->getClientData());
}

public function testBindMultipleExpandedWithEmptyField()
{
$form = $this->factory->create('choice', null, array(
Expand Down
0