]>
Commit | Line | Data |
---|---|---|
f19f9f62 KG |
1 | <?php |
2 | ||
3 | namespace Wallabag\CoreBundle\Form\Type; | |
4 | ||
5 | use Symfony\Component\Form\AbstractType; | |
619cc453 JB |
6 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
7 | use Symfony\Component\Form\Extension\Core\Type\TextType; | |
f19f9f62 KG |
8 | use Symfony\Component\Form\FormBuilderInterface; |
9 | use Symfony\Component\OptionsResolver\OptionsResolver; | |
f19f9f62 KG |
10 | use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer; |
11 | ||
12 | class TaggingRuleType extends AbstractType | |
13 | { | |
14 | public function buildForm(FormBuilderInterface $builder, array $options) | |
15 | { | |
16 | $builder | |
4094ea47 | 17 | ->add('rule', TextType::class, [ |
0d42217e JB |
18 | 'required' => true, |
19 | 'label' => 'config.form_rules.rule_label', | |
4094ea47 JB |
20 | ]) |
21 | ->add('save', SubmitType::class, [ | |
0d42217e | 22 | 'label' => 'config.form.save', |
4094ea47 | 23 | ]) |
f19f9f62 KG |
24 | ; |
25 | ||
26 | $tagsField = $builder | |
4094ea47 | 27 | ->create('tags', TextType::class, [ |
0d42217e | 28 | 'label' => 'config.form_rules.tags_label', |
4094ea47 | 29 | ]) |
f19f9f62 KG |
30 | ->addModelTransformer(new StringToListTransformer(',')); |
31 | ||
32 | $builder->add($tagsField); | |
33 | } | |
34 | ||
35 | public function configureOptions(OptionsResolver $resolver) | |
36 | { | |
4094ea47 | 37 | $resolver->setDefaults([ |
f19f9f62 | 38 | 'data_class' => 'Wallabag\CoreBundle\Entity\TaggingRule', |
4094ea47 | 39 | ]); |
f19f9f62 KG |
40 | } |
41 | ||
619cc453 | 42 | public function getBlockPrefix() |
f19f9f62 KG |
43 | { |
44 | return 'tagging_rule'; | |
45 | } | |
46 | } |