bug #15662 [Form][2.7][ Choice type] fixed groups with empty array. (aitboudad)
This PR was merged into the 2.7 branch.
Discussion
----------
[Form][2.7][ Choice type] fixed groups with empty array.
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #15634
| License | MIT
| Doc PR | ~
- [x] test
Commits
-------
835aa78
[Form][2.7][ Choice type] fixed groups with empty array.
This commit is contained in:
commit
db8420e6d5
@ -172,6 +172,10 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
|
|||||||
private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews)
|
private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews)
|
||||||
{
|
{
|
||||||
foreach ($groupBy as $key => $value) {
|
foreach ($groupBy as $key => $value) {
|
||||||
|
if (null === $value) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Add the contents of groups to new ChoiceGroupView instances
|
// Add the contents of groups to new ChoiceGroupView instances
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$preferredViewsForGroup = array();
|
$preferredViewsForGroup = array();
|
||||||
|
@ -536,6 +536,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$list = new ArrayChoiceList(array(
|
$list = new ArrayChoiceList(array(
|
||||||
'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2),
|
'Group 1' => array('A' => $this->obj1, 'B' => $this->obj2),
|
||||||
'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4),
|
'Group 2' => array('C' => $this->obj3, 'D' => $this->obj4),
|
||||||
|
'Group empty' => array(),
|
||||||
));
|
));
|
||||||
|
|
||||||
$view = $this->factory->createView(
|
$view = $this->factory->createView(
|
||||||
|
Reference in New Issue
Block a user