src/AppBundle/Form/ContactFormType.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace AppBundle\Form;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\Validator\Constraints\IsTrue;
  11. use Symfony\Component\Validator\Constraints\Length;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. class ContactFormType extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options): void
  16.     {
  17.         $builder
  18.             ->add('name'TextType::class, [
  19.                 'label' => 'app.general.gemini.contactform.name',
  20.                 'required' => true,
  21.                 'constraints' => [
  22.                     new NotBlank(),
  23.                     new Length(['min' => 3]),
  24.                 ],
  25.             ])
  26.             ->add('surname'TextType::class, [
  27.                 'label' => 'app.general.gemini.contactform.surname',
  28.                 'required' => true,
  29.                 'constraints' => [
  30.                     new NotBlank(),
  31.                     new Length(['min' => 3]),
  32.                 ],
  33.             ])
  34.             ->add('email'TextType::class, [
  35.                 'label' => 'app.general.gemini.contactform.email',
  36.                 'required' => true,
  37.                 'constraints' => [
  38.                     new NotBlank(),
  39.                     new Length(['min' => 3]),
  40.                 ],
  41.             ])
  42.             ->add('company'TextType::class, [
  43.                 'label' => 'app.general.gemini.contactform.company',
  44.                 'required' => false,
  45.             ])
  46.             ->add('message'TextType::class, [
  47.                 'label' => 'app.general.gemini.contactform.message',
  48.                 'required' => true,
  49.                 'constraints' => [
  50.                     new NotBlank(),
  51.                     new Length(['min' => 3]),
  52.                 ],
  53.             ])
  54.             ->add('phone'TextType::class, [
  55.                 'label' => 'app.general.gemini.contactform.phone',
  56.                 'required' => false,
  57.             ])
  58.             ->add('topic'ChoiceType::class, [
  59.                 'label' => 'app.general.gemini.contactform.topic',
  60.                 'required' => true,
  61.                 'expanded' => true,
  62.                 'multiple' => false,
  63.                 'choices' => [
  64.                     'app.general.gemini.contactform.topic2' => 'office',
  65.                     'app.general.gemini.contactform.topic1' => 'suppliers',
  66.                     'app.general.gemini.contactform.topic3' => 'renting',
  67.                     'app.general.gemini.contactform.topic4' => 'GDPR',
  68.                 ],
  69.                 'constraints' => [
  70.                     new NotBlank(),
  71.                     new Length(['min' => 3]),
  72.                 ],
  73.             ])
  74.             ->add('subject'TextType::class, [
  75.                 'label' => 'app.general.gemini.contactform.subject',
  76.                 'required' => false,
  77.             ])
  78.             ->add('agreement1'CheckboxType::class, [
  79.                 'label' => 'app.general.gemini.contactform.agreement1',
  80.                 'required' => true,
  81.                 'constraints' => [
  82.                     new IsTrue([
  83.                         'message' => 'app.general.gemini.form.checkboxvalidation',
  84.                     ]),
  85.                 ],
  86.             ])
  87.             ->add('_submit'SubmitType::class, [
  88.                 'label' => 'app.general.gemini.contactform.submit',
  89.                 'attr' => [
  90.                     'class' => 'col-5 primary-btn orange-btn',
  91.                 ],
  92.             ]);
  93.     }
  94. }