src/Form/Type/Frontend/ContactType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form\Type\Frontend;
  3. use App\Form\Type\EWZRecaptchaCustomType;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints\Email;
  12. use Symfony\Component\Validator\Constraints\Length;
  13. use Symfony\Component\Validator\Constraints\NotBlank;
  14. class ContactType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options): void
  17.     {
  18.         $builder
  19.             ->add('firstname'TextType::class, [
  20.                 'label' => 'frontend.landing.contact.form.label.firstname',
  21.                 'constraints' => [
  22.                     new NotBlank(),
  23.                 ],
  24.             ])
  25.             ->add('lastname'TextType::class, [
  26.                 'label' => 'frontend.landing.contact.form.label.lastname',
  27.                 'constraints' => [
  28.                     new NotBlank(),
  29.                 ],
  30.             ])
  31.             ->add('email'EmailType::class, [
  32.                 'label' => 'frontend.landing.contact.form.label.email',
  33.                 'constraints' => [
  34.                     new NotBlank(),
  35.                     new Email(),
  36.                 ],
  37.             ])
  38.             ->add('message'TextareaType::class, [
  39.                 'label' => 'frontend.landing.contact.form.label.message',
  40.                 'constraints' => [
  41.                     new NotBlank(),
  42.                     new Length(['min' => 10]),
  43.                 ],
  44.             ])
  45.             ->add('recaptcha'EWZRecaptchaCustomType::class)
  46.             ->add('send'SubmitType::class, [
  47.                 'label' => 'frontend.landing.contact.form.label.submit',
  48.                 'attr' => [
  49.                     'class' => 'btn06',
  50.                 ],
  51.             ])
  52.         ;
  53.     }
  54.     public function configureOptions(OptionsResolver $resolver): void
  55.     {
  56.         $resolver->setDefaults([
  57.             'translation_domain' => 'landing',
  58.         ]);
  59.     }
  60. }