|
14 | 14 | use Propel\Bundle\PropelBundle\Form\ChoiceList\PropelChoiceLoader; |
15 | 15 | use Propel\Bundle\PropelBundle\Form\DataTransformer\CollectionToArrayTransformer; |
16 | 16 | use Symfony\Component\Form\AbstractType; |
17 | | -use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; |
18 | | -use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; |
19 | | -use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator; |
20 | 17 | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
21 | 18 | use Symfony\Component\Form\FormBuilderInterface; |
22 | 19 | use Symfony\Component\OptionsResolver\Options; |
|
37 | 34 | * public function buildForm(FormBuilderInterface $builder, array $options) |
38 | 35 | * { |
39 | 36 | * $builder |
40 | | - * ->add('product', 'model', array( |
| 37 | + * ->add('product', ModelType::class, array( |
41 | 38 | * 'class' => 'Model\Product', |
42 | 39 | * 'query' => ProductQuery::create() |
43 | 40 | * ->filterIsActive(true) |
|
55 | 52 | */ |
56 | 53 | class ModelType extends AbstractType |
57 | 54 | { |
58 | | - /** |
59 | | - * @var ChoiceListFactoryInterface |
60 | | - */ |
61 | | - private $choiceListFactory; |
62 | | - |
63 | | - /** |
64 | | - * ModelType constructor. |
65 | | - * |
66 | | - * @param PropertyAccessorInterface|null $propertyAccessor |
67 | | - * @param ChoiceListFactoryInterface|null $choiceListFactory |
68 | | - */ |
69 | | - public function __construct(PropertyAccessorInterface $propertyAccessor = null, ChoiceListFactoryInterface $choiceListFactory = null) |
70 | | - { |
71 | | - $this->choiceListFactory = $choiceListFactory ?: new PropertyAccessDecorator( |
72 | | - new DefaultChoiceListFactory(), |
73 | | - $propertyAccessor |
74 | | - ); |
75 | | - } |
76 | | - |
77 | 55 | /** |
78 | 56 | * Creates the label for a choice. |
79 | 57 | * |
@@ -133,7 +111,6 @@ public function configureOptions(OptionsResolver $resolver) |
133 | 111 | if (null === $options['choices']) { |
134 | 112 |
|
135 | 113 | $propelChoiceLoader = new PropelChoiceLoader( |
136 | | - $this->choiceListFactory, |
137 | 114 | $options['class'], |
138 | 115 | $options['query'] |
139 | 116 | ); |
@@ -252,6 +229,9 @@ public function getBlockPrefix() |
252 | 229 | return 'model'; |
253 | 230 | } |
254 | 231 |
|
| 232 | + /** |
| 233 | + * {@inheritdoc} |
| 234 | + */ |
255 | 235 | public function getParent() |
256 | 236 | { |
257 | 237 | return ChoiceType::class; |
|
0 commit comments