Skip to content

Commit bf2becd

Browse files
committed
[Form][2.7][ Choice type] fixed groups with empty array.
1 parent 69707f5 commit bf2becd

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

ChoiceList/Factory/DefaultChoiceListFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
172172
private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews)
173173
{
174174
foreach ($groupBy as $key => $value) {
175+
if (null === $value) {
176+
continue;
177+
}
178+
175179
// Add the contents of groups to new ChoiceGroupView instances
176180
if (is_array($value)) {
177181
$preferredViewsForGroup = array();

Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ public function testCreateViewFlatGroupByOriginalStructure()
536536
$list = new ArrayChoiceList(array(
537537
'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2),
538538
'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4),
539+
'Group empty' => array(),
539540
));
540541

541542
$view = $this->factory->createView(

0 commit comments

Comments
 (0)