src/Form/EvolutionType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Evolution;
  4. use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type;
  5. use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  8. use Symfony\Component\Form\Extension\Core\Type\UrlType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. class EvolutionType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options): void
  14.     {
  15.         $builder
  16.             ->add('customer_information'CustomerInformationType::class, [
  17.                 'label' => false,
  18.             ])
  19.             ->add('description'TextareaType::class, [
  20.                 'label' => 'Décrivez votre besoin *',
  21.                 'required' => true,
  22.                 'attr' => [
  23.                     'class' => 'form-control',
  24.                     'rows' => '5',
  25.                 ],
  26.             ])
  27.             ->add('url'UrlType::class, [
  28.                 'label' => 'Si votre demande concèrne un site déjà existant, merci de donner l\'URL de ce site',
  29.                 'required' => false,
  30.             ])
  31.             ->add('recaptcha'EWZRecaptchaV3Type::class, [
  32.                 'action_name' => 'contact',
  33.                 'constraints' => [
  34.                     new IsTrueV3(),
  35.                 ],
  36.                 'attr' => [
  37.                         'theme' => 'light',
  38.                         'type' => 'image',
  39.                         'size' => 'invisible',              // set size to invisible
  40.                         'defer' => true,
  41.                         'async' => true,
  42.                         'callback' => 'onReCaptchaSuccess'// callback will be set by default if not defined (along with JS function that validate the form on success)
  43.                         'bind' => 'btn_submit',             // this is the id of the form submit button
  44.                 ],
  45.             ])
  46.         ;
  47.     }
  48.     public function configureOptions(OptionsResolver $resolver): void
  49.     {
  50.         $resolver->setDefaults([
  51.             'data_class' => Evolution::class,
  52.         ]);
  53.     }
  54. }