1313use Symfony \Component \Form \FormBuilderInterface ;
1414use Symfony \Component \Form \Extension \Core \Type \CheckboxType ;
1515use Symfony \Component \Form \Extension \Core \Type \EmailType ;
16- use Symfony \Component \Form \Extension \Core \Type \SubmitType ;
1716use Symfony \Component \Form \Extension \Core \Type \TextareaType ;
1817use Symfony \Component \Form \Extension \Core \Type \TextType ;
1918use Symfony \Component \OptionsResolver \OptionsResolver ;
@@ -62,17 +61,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6261 ))
6362 ;
6463 }
65- $ builder
66- ->add ('gdpr ' , CheckboxType::class, array (
67- 'label ' => 'text.gdpr ' ,
68- 'required ' => true ,
69- 'mapped ' => false ,
70- ))
71- ->add ('submit ' , SubmitType::class, array (
72- 'label ' => 'label.send ' ,
73- 'attr ' => array ('class ' => 'btn btn-block btn-lg btn-primary ' ),
74- ))
75- ;
64+ if ($ options ['gdpr ' ] === true ) {
65+ $ builder
66+ ->add ('gdpr ' , CheckboxType::class, array (
67+ 'label ' => 'text.gdpr ' ,
68+ 'required ' => true ,
69+ 'mapped ' => false ,
70+ ));
71+ }
7672 }
7773
7874 public function configureOptions (OptionsResolver $ resolver )
@@ -83,6 +79,9 @@ public function configureOptions(OptionsResolver $resolver)
8379 'translation_domain ' => 'contactForm ' ,
8480 ));
8581
86- $ resolver ->setRequired ('receiveCopy ' );
82+ $ resolver
83+ ->setRequired ('receiveCopy ' )
84+ ->setRequired ('gdpr ' )
85+ ;
8786 }
8887}
0 commit comments