Skip to content

Commit e7234d8

Browse files
committed
[Form] fix tests added by #17760 by removing choices_as_values
1 parent f41fa21 commit e7234d8

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
148148
// with the string value so it can be matched in
149149
// {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper::mapDataToForms()}
150150
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
151-
$choiceList = $event->getForm()->getConfig()->getOption('choice_list');
151+
$choiceList = $event->getForm()->getConfig()->getAttribute('choice_list');
152152
$value = current($choiceList->getValuesForChoices(array($event->getData())));
153153
$event->setData((string) $value);
154154
});

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
2929
'No' => false,
3030
'n/a' => '',
3131
);
32-
32+
3333
private $objectChoices;
3434

3535
protected $groupedChoices = array(
@@ -104,7 +104,6 @@ public function testChoiceListWithScalarValues()
104104
{
105105
$view = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
106106
'choices' => $this->scalarChoices,
107-
'choices_as_values' => true,
108107
))->createView();
109108

110109
$this->assertSame('1', $view->vars['choices'][0]->value);
@@ -119,7 +118,6 @@ public function testChoiceListWithScalarValuesAndFalseAsPreSetData()
119118
{
120119
$view = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', false, array(
121120
'choices' => $this->scalarChoices,
122-
'choices_as_values' => true,
123121
))->createView();
124122

125123
$this->assertTrue($view->vars['is_selected']($view->vars['choices'][1]->value, $view->vars['value']), 'False value should be pre selected');
@@ -129,7 +127,6 @@ public function testExpandedChoiceListWithScalarValues()
129127
{
130128
$view = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
131129
'choices' => $this->scalarChoices,
132-
'choices_as_values' => true,
133130
'expanded' => true,
134131
))->createView();
135132

@@ -142,7 +139,6 @@ public function testExpandedChoiceListWithScalarValuesAndFalseAsPreSetData()
142139
{
143140
$view = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', false, array(
144141
'choices' => $this->scalarChoices,
145-
'choices_as_values' => true,
146142
'expanded' => true,
147143
))->createView();
148144

@@ -218,7 +214,6 @@ public function testPlaceholderWithBooleanChoices()
218214
'No' => false,
219215
),
220216
'placeholder' => 'Select an option',
221-
'choices_as_values' => true,
222217
));
223218

224219
$view = $form->createView();
@@ -240,7 +235,6 @@ public function testPlaceholderWithBooleanChoicesWithFalseAsPreSetData()
240235
'No' => false,
241236
),
242237
'placeholder' => 'Select an option',
243-
'choices_as_values' => true,
244238
));
245239

246240
$view = $form->createView();
@@ -262,7 +256,6 @@ public function testPlaceholderWithExpandedBooleanChoices()
262256
'No' => false,
263257
),
264258
'placeholder' => 'Select an option',
265-
'choices_as_values' => true,
266259
));
267260

268261
$this->assertTrue(isset($form['placeholder']), 'Placeholder should be set');
@@ -287,7 +280,6 @@ public function testPlaceholderWithExpandedBooleanChoicesAndWithFalseAsPreSetDat
287280
'No' => false,
288281
),
289282
'placeholder' => 'Select an option',
290-
'choices_as_values' => true,
291283
));
292284

293285
$this->assertTrue(isset($form['placeholder']), 'Placeholder should be set');

0 commit comments

Comments
 (0)