src/Form/SupportType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Support;
  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\CheckboxType;
  8. use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
  9. use Symfony\Component\Form\Extension\Core\Type\DateType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  11. use Symfony\Component\Form\Extension\Core\Type\UrlType;
  12. use Symfony\Component\Form\FormBuilderInterface;
  13. use Symfony\Component\OptionsResolver\OptionsResolver;
  14. class SupportType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options): void
  17.     {
  18.         $builder
  19.             ->add('customer_information'CustomerInformationType::class, [
  20.                 'label' => false,
  21.             ])
  22.             ->add('description'TextareaType::class, [
  23.                 'label' => 'Décrivez votre problème *',
  24.                 'required' => true,
  25.                 'attr' => [
  26.                     'class' => 'form-control',
  27.                     'rows' => '5',
  28.                 ],
  29.             ])
  30.             ->add('actions_realized'TextareaType::class, [
  31.                 'label' => 'Quelle(s) action(s) avez vous réalisé ? *',
  32.                 'required' => true,
  33.                 'attr' => [
  34.                     'class' => 'form-control',
  35.                     'rows' => '5',
  36.                     'placeholder' => 'ex : «Lorsque je clique sur l\'onglet \'Clients > Ajouter\' , si je ne renseigne pas l\'adresse du client, le site bug et renvoie une erreur»',
  37.                 ],
  38.             ])
  39.             ->add('expected_actions'TextareaType::class, [
  40.                 'label' => 'Quelle(s) action(s) attendez-vous de l\'application ?',
  41.                 'required' => false,
  42.                 'attr' => [
  43.                     'class' => 'form-control',
  44.                     'rows' => '5',
  45.                 ],
  46.             ])
  47.             ->add('url'UrlType::class, [
  48.                 'label' => 'Quelle est l\'URL où est apparu le problème ? *',
  49.                 'required' => true,
  50.             ])
  51.             ->add('date_time'DateTimeType::class, [
  52.                 'label' => 'À quelle heure le problème est il apparu ? *',
  53.                 'widget' => 'single_text',
  54.                 'html5' => true,
  55.                 'required' => true,
  56.             ])
  57.             ->add('is_blocking'CheckboxType::class, [
  58.                 'label' => 'Le problème vous empêche t il de travailler dans l\'immédiat ?',
  59.                 'required' => false,
  60.                 'attr' => [
  61.                     'class' => 'form-check-input',
  62.                 ],
  63.                 'row_attr' => [
  64.                     'class' => 'form-check form-switch',
  65.                 ],
  66.             ])
  67.             ->add('blocking_description'TextareaType::class, [
  68.                 'label' => 'Si oui, pourquoi ?',
  69.                 'required' => false,
  70.                 'attr' => [
  71.                     'class' => 'form-control',
  72.                     'rows' => '5',
  73.                 ],
  74.             ])
  75.             ->add('blocking_deadline'DateType::class, [
  76.                 'label' => 'A partir de quelle date avez vous impérativement besoin que la modification soit faite ?',
  77.                 'widget' => 'single_text',
  78.                 'html5' => true,
  79.                 'required' => false,
  80.             ])
  81.             ->add('another_details'TextareaType::class, [
  82.                 'label' => 'Autres remarques',
  83.                 'required' => false,
  84.                 'attr' => [
  85.                     'class' => 'form-control',
  86.                     'rows' => '5',
  87.                 ],
  88.             ])
  89.             ->add('recaptcha'EWZRecaptchaV3Type::class, [
  90.                 'action_name' => 'contact',
  91.                 'constraints' => [
  92.                     new IsTrueV3(),
  93.                 ],
  94.                 'attr' => [
  95.                         'theme' => 'light',
  96.                         'type' => 'image',
  97.                         'size' => 'invisible',              // set size to invisible
  98.                         'defer' => true,
  99.                         'async' => true,
  100.                         'callback' => 'onReCaptchaSuccess'// callback will be set by default if not defined (along with JS function that validate the form on success)
  101.                         'bind' => 'btn_submit',             // this is the id of the form submit button
  102.                 ],
  103.             ])
  104.         ;
  105.     }
  106.     public function configureOptions(OptionsResolver $resolver): void
  107.     {
  108.         $resolver->setDefaults([
  109.             'data_class' => Support::class,
  110.         ]);
  111.     }
  112. }