File tree 2 files changed +6
-14
lines changed
src/Symfony/Component/Form/Tests
2 files changed +6
-14
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Form \ChoiceList \View \ChoiceGroupView ;
15
15
use Symfony \Component \Form \ChoiceList \View \ChoiceView ;
16
- use Symfony \Component \Form \Tests \Fixtures \ChoiceSubType ;
17
16
18
17
class ChoiceTypeTest extends \Symfony \Component \Form \Test \TypeTestCase
19
18
{
@@ -1491,14 +1490,15 @@ public function testInitializeWithDefaultObjectChoice()
1491
1490
public function testCustomChoiceTypeDoesNotInheritChoiceLabels ()
1492
1491
{
1493
1492
$ builder = $ this ->factory ->createBuilder ();
1494
- $ builder ->add ('choice ' , 'choice ' , array (
1493
+ $ builder ->add ('choice ' , 'Symfony\Component\Form\Extension\Core\Type\ChoiceType ' , array (
1495
1494
'choices ' => array (
1496
1495
'1 ' => '1 ' ,
1497
1496
'2 ' => '2 ' ,
1498
1497
),
1498
+ 'choices_as_values ' => true ,
1499
1499
)
1500
1500
);
1501
- $ builder ->add ('subChoice ' , new ChoiceSubType () );
1501
+ $ builder ->add ('subChoice ' , ' Symfony\Component\Form\Tests\Fixtures\ ChoiceSubType' );
1502
1502
$ form = $ builder ->getForm ();
1503
1503
1504
1504
// The default 'choices' normalizer would fill the $choiceLabels, but it has been replaced
Original file line number Diff line number Diff line change 16
16
17
17
/**
18
18
* @author Paráda József <joczy.parada@gmail.com>
19
- */
19
+ */
20
20
class ChoiceSubType extends AbstractType
21
21
{
22
22
/**
23
23
* {@inheritdoc}
24
24
*/
25
25
public function configureOptions (OptionsResolver $ resolver )
26
26
{
27
- $ resolver ->setDefaults (array ('expanded ' => true ));
27
+ $ resolver ->setDefaults (array ('expanded ' => true , ' choices_as_values ' => true ));
28
28
$ resolver ->setNormalizer ('choices ' , function () {
29
29
return array (
30
30
'attr1 ' => 'Attribute 1 ' ,
@@ -33,19 +33,11 @@ public function configureOptions(OptionsResolver $resolver)
33
33
});
34
34
}
35
35
36
- /**
37
- * {@inheritdoc}
38
- */
39
- public function getName ()
40
- {
41
- return 'sub_choice ' ;
42
- }
43
-
44
36
/**
45
37
* {@inheritdoc}
46
38
*/
47
39
public function getParent ()
48
40
{
49
- return 'choice ' ;
41
+ return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType ' ;
50
42
}
51
43
}
You can’t perform that action at this time.
0 commit comments