Skip to content

Commit

Permalink
[Form] Fixed empty value in choice fields
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed Apr 6, 2011
1 parent e476231 commit 3482ff7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Symfony/Component/Form/Form.php
Expand Up @@ -459,7 +459,6 @@ public function bind($clientData)
}
}


// Merge form data from children into existing client data
if (count($this->children) > 0 && $this->dataMapper) {
$this->dataMapper->mapFormsToData($this->children, $clientData);
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Form/Type/ChoiceType.php
Expand Up @@ -92,13 +92,17 @@ public function buildRenderer(ThemeRendererInterface $renderer, FormInterface $f

public function getDefaultOptions(array $options)
{
$multiple = isset($options['multiple']) && $options['multiple'];
$expanded = isset($options['expanded']) && $options['expanded'];

return array(
'multiple' => false,
'expanded' => false,
'choice_list' => null,
'choices' => array(),
'preferred_choices' => array(),
'csrf_protection' => false,
'empty_data' => $multiple || $expanded ? array() : '',
);
}

Expand Down

1 comment on commit 3482ff7

@henrikbjorn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this introduced a bug when you have a choice field that are expanded but not multiple will trigger the form to have extra data. This is what print_r printed out for $form->getExtraData();

array (
    [] = 1,
)

Please sign in to comment.