Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a72a5fa

Browse filesBrowse files
committed
[Form] Add support for \Traversable in 'choices' param of ChoiceType
1 parent 25ff59b commit a72a5fa
Copy full SHA for a72a5fa

File tree

2 files changed

+8
-1
lines changed
Filter options

2 files changed

+8
-1
lines changed

‎src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
239239
));
240240

241241
$resolver->setAllowedTypes(array(
242-
'choices' => array('null', 'array'),
242+
'choices' => array('null', 'array', 'Traversable'),
243243
'choice_list' => array('null', 'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'),
244244
'preferred_choices' => 'array',
245245
));

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,13 @@ public function testInitializeWithDefaultObjectChoice()
16721672
$form->getViewData();
16731673
}
16741674

1675+
public function testChoicesOptionSupportsTraversable()
1676+
{
1677+
$this->factory->create('choice', null, array(
1678+
'choices' => new \ArrayObject($this->choices),
1679+
));
1680+
}
1681+
16751682
/**
16761683
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
16771684
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.