src/Form/ContactType.php line 21

Open in your IDE?
  1. <?php
  2. //----------------------------------------------------------------------
  3. // src/Form/ContactType.php
  4. //----------------------------------------------------------------------
  5. namespace App\Form;
  6. use Symfony\Component\Validator\Constraints\Valid;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. use Symfony\Component\Validator\Constraints\NotNull;
  14. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  15. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  16. use App\Entity\Contact;
  17. class ContactType extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options): void
  20.     {        
  21.         $builder->add('firstname'TextType::class, array(
  22.             'required'    => true,
  23.             'label'        => false,
  24.         ));
  25.         $builder->add('lastname'TextType::class, array(
  26.             'required'    => true,
  27.             'label'        => false,
  28.         ));
  29.         $builder->add('email'TextType::class, array(
  30.             'required'    => true,
  31.             'label'        => false,
  32.         ));
  33.         $builder->add('phone'TextType::class, array(
  34.             'required'    => true,
  35.             'label'        => false,
  36.         ));
  37.         $builder->add('message'TextType::class, array(
  38.             'required'    => true,
  39.             'label'        => false,
  40.         ));
  41.         $builder->add('captcha'Recaptcha3Type::class, [
  42.             'constraints' => new Recaptcha3(['message' => 'There were problems with your captcha. Please try again or contact with support and provide following code(s): {{ errorCodes }}']),
  43.             'action_name' => 'contact',
  44.         ]);
  45.     }
  46.     public function configureOptions(OptionsResolver $resolver): void
  47.     {
  48.         $resolver->setDefaults([
  49.             'data_class' => Contact::class,
  50.         ]);
  51.     }
  52. }