src/AppBundle/Form/FranchiseFormType.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\SubmitType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Validator\Constraints\IsTrue;
  11. use Symfony\Component\Validator\Constraints\Length;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. class FranchiseFormType 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.franchiseform.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.franchiseform.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.franchiseform.email',
  36.                 'required' => true,
  37.                 'constraints' => [
  38.                     new NotBlank(),
  39.                     new Length(['min' => 3]),
  40.                 ],
  41.             ])
  42.             ->add('city'TextType::class, [
  43.                 'label' => 'app.general.gemini.franchiseform.city',
  44.                 'required' => true,
  45.                 'constraints' => [
  46.                     new NotBlank(),
  47.                     new Length(['min' => 3]),
  48.                 ],
  49.             ])
  50.             ->add('phone'TextType::class, [
  51.                 'label' => 'app.general.gemini.franchiseform.phone',
  52.                 'required' => true,
  53.                 'constraints' => [
  54.                     new NotBlank(),
  55.                     new Length(['min' => 3]),
  56.                 ],
  57.             ])
  58.             ->add('message'TextType::class, [
  59.                 'label' => 'app.general.gemini.franchiseform.message',
  60.                 'required' => false,
  61.             ])
  62.             ->add('agreement1'CheckboxType::class, [
  63.                 'label' => 'app.general.gemini.franchiseform.agreement1',
  64.                 'required' => true,
  65.                 'constraints' => [
  66.                     new IsTrue([
  67.                         'message' => 'app.general.gemini.form.checkboxvalidation',
  68.                     ]),
  69.                 ],
  70.             ])
  71.             ->add('_submit'SubmitType::class, [
  72.                 'label' => 'app.general.gemini.franchiseform.submit',
  73.                 'attr' => [
  74.                     'class' => 'col-5 primary-btn orange-btn',
  75.                 ],
  76.             ]);
  77.     }
  78.     public function configureOptions(OptionsResolver $resolver): void
  79.     {
  80.         $resolver->setDefaults([
  81.             'cascade_validation' => true,
  82.         ]);
  83.     }
  84. }