[Form][2.7][ Choice type] fixed groups with empty array.

This commit is contained in:
Abdellatif Ait boudad 2015-08-31 16:16:04 +00:00
parent 5368a4287a
commit 835aa788d4
2 changed files with 5 additions and 0 deletions

View File

@ -172,6 +172,10 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews)
{
foreach ($groupBy as $key => $value) {
if (null === $value) {
continue;
}
// Add the contents of groups to new ChoiceGroupView instances
if (is_array($value)) {
$preferredViewsForGroup = array();

View File

@ -536,6 +536,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$list = new ArrayChoiceList(array(
'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2),
'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4),
'Group empty' => array(),
));
$view = $this->factory->createView(