src/Form/ContactFormType.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\TelType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints\IsTrue;
  12. class ContactFormType extends AbstractType
  13. {
  14.     public function buildForm(FormBuilderInterface $builder, array $options): void
  15.     {
  16.         $builder
  17.             ->add('societe'TextType::class, [
  18.                 'label' => false,
  19.                 'attr' => [
  20.                     'class' => 'form-control',
  21.                 ],
  22.             ])
  23.             ->add('email'EmailType::class, [
  24.                 'label' => false,
  25.                 'attr' => [
  26.                     'class' => 'form-control',
  27.                 ],
  28.             ])
  29.             ->add('telephone'TelType::class, [
  30.                 'label' => false,
  31.                 'attr' => [
  32.                     'class' => 'form-control',
  33.                     'pattern' => '[0-9]*',
  34.                 ],
  35.             ])
  36.             ->add('message'TextareaType::class, [
  37.                 'label' => false,
  38.                 'attr' => [
  39.                     'class' => 'form-control',
  40.                     'rows' => 5,
  41.                 ],
  42.             ])
  43.             ->add('agreeTerms'CheckboxType::class, [
  44.                 'label' => false,
  45.                 'mapped' => false,
  46.                 'constraints' => [
  47.                     new IsTrue([
  48.                         'message' => 'Vous devez accepter les conditions.',
  49.                     ]),
  50.                 ],
  51.             ])
  52.         ;
  53.     }
  54.     public function configureOptions(OptionsResolver $resolver): void
  55.     {
  56.         $resolver->setDefaults([
  57.             // Configure your form options here
  58.         ]);
  59.     }
  60. }