Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 80 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
CriterePrincipeFondamentalType | |
0.00% |
0 / 80 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
buildForm | |
0.00% |
0 / 71 |
|
0.00% |
0 / 1 |
2 | |||
configureOptions | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace App\Domain\AIPD\Form\Type; |
6 | |
7 | use App\Domain\AIPD\Model\CriterePrincipeFondamental; |
8 | use Knp\DictionaryBundle\Form\Type\DictionaryType; |
9 | use Symfony\Component\Form\AbstractType; |
10 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
11 | use Symfony\Component\Form\Extension\Core\Type\FileType; |
12 | use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
13 | use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
14 | use Symfony\Component\Form\Extension\Core\Type\TextType; |
15 | use Symfony\Component\Form\FormBuilderInterface; |
16 | use Symfony\Component\OptionsResolver\OptionsResolver; |
17 | use Symfony\Component\Validator\Constraints\File; |
18 | |
19 | class CriterePrincipeFondamentalType extends AbstractType |
20 | { |
21 | protected string $maxSize; |
22 | |
23 | public function __construct(string $maxSize) |
24 | { |
25 | $this->maxSize = $maxSize; |
26 | } |
27 | |
28 | public function buildForm(FormBuilderInterface $builder, array $options) |
29 | { |
30 | $builder |
31 | ->add('label', TextType::class, [ |
32 | 'purify_html' => true, |
33 | ]) |
34 | ->add('labelLivrable', TextType::class, [ |
35 | 'attr' => [ |
36 | 'maxlength' => 255, |
37 | ], |
38 | 'purify_html' => true, |
39 | ]) |
40 | ->add('reponse', DictionaryType::class, [ |
41 | 'name' => 'reponse_critere_fondamental', |
42 | ]) |
43 | ->add('isVisible', CheckboxType::class, [ |
44 | 'label' => false, |
45 | 'required' => false, |
46 | ]) |
47 | ->add('texteConformite', TextareaType::class, [ |
48 | 'attr' => [ |
49 | 'maxlength' => 1000, |
50 | 'rows' => 1, |
51 | 'class' => 'textareaheight', |
52 | ], |
53 | 'purify_html' => true, |
54 | ]) |
55 | ->add('texteNonConformite', TextareaType::class, [ |
56 | 'attr' => [ |
57 | 'maxlength' => 1000, |
58 | 'rows' => 1, |
59 | 'class' => 'textareaheight', |
60 | ], |
61 | 'purify_html' => true, |
62 | ]) |
63 | ->add('texteNonApplicable', TextareaType::class, [ |
64 | 'attr' => [ |
65 | 'maxlength' => 1000, |
66 | 'rows' => 1, |
67 | 'class' => 'textareaheight', |
68 | ], |
69 | 'purify_html' => true, |
70 | ]) |
71 | ->add('justification', TextareaType::class, [ |
72 | 'required' => false, |
73 | 'attr' => [ |
74 | 'maxlength' => 2000, |
75 | 'rows' => 1, |
76 | 'class' => 'textareaheight', |
77 | ], |
78 | 'purify_html' => true, |
79 | ]) |
80 | ->add('deleteFile', HiddenType::class, [ |
81 | 'data' => 0, |
82 | ]) |
83 | ->add('fichierFile', FileType::class, [ |
84 | 'required' => false, |
85 | 'constraints' => [ |
86 | new File([ |
87 | 'maxSize' => $this->maxSize, |
88 | 'mimeTypes' => [ |
89 | 'image/jpeg', |
90 | 'image/png', |
91 | ], |
92 | 'mimeTypesMessage' => 'aipd_validator.fichier.file', |
93 | 'groups' => ['default'], |
94 | ]), |
95 | ], |
96 | 'attr' => [ |
97 | 'accept' => 'image/*', |
98 | ], |
99 | ]) |
100 | ; |
101 | } |
102 | |
103 | /** |
104 | * Provide type options. |
105 | */ |
106 | public function configureOptions(OptionsResolver $resolver) |
107 | { |
108 | $resolver |
109 | ->setDefaults([ |
110 | 'data_class' => CriterePrincipeFondamental::class, |
111 | 'validation_groups' => [ |
112 | 'default', |
113 | 'aipd', |
114 | ], |
115 | ]); |
116 | } |
117 | } |