src/Form/ContactType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\FormBuilderInterface;
  5. use Symfony\Component\OptionsResolver\OptionsResolver;
  6. use Captcha\Bundle\CaptchaBundle\Form\Type\CaptchaType;
  7. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Captcha\Bundle\CaptchaBundle\Validator\Constraints\ValidCaptcha;
  10. class ContactType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options)
  13.     {
  14.         $builder
  15.             ->add('name'null, [
  16.                 'label' => 'Nombre',
  17.                 'required' => true
  18.             ])
  19.             ->add('email'EmailType::class, [
  20.                 'label' => 'Email',
  21.                 'required' => true,
  22.             ])
  23.             ->add('message'TextareaType::class, [
  24.                 'label' => 'Mensaje',
  25.                 'required' => true
  26.             ])
  27.             ->add('captchaCode'CaptchaType::class, [
  28.                 'captchaConfig' => 'ExampleCaptcha',
  29.                 'constraints' => [
  30.                     new ValidCaptcha([
  31.                         'message' => 'Invalid captcha, please try again',
  32.                     ]),
  33.                 ]
  34.             ])
  35.             ;
  36.     }
  37.     public function configureOptions(OptionsResolver $resolver)
  38.     {
  39.         $resolver->setDefaults([
  40.             // Configure your form options here
  41.         ]);
  42.     }
  43. }