src/Form/ContactType.php line 13

  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Contact;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  10. class ContactType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.         ->add('name'TextType::class, [
  16.             'label' => 'Nom',
  17.             'attr' => [
  18.                 'class' => 'form-control border-0 bg-light px-4'
  19.             ]
  20.         ])
  21.         ->add('email'EmailType::class, [
  22.             'label' => 'Votre email',
  23.             'attr' => [
  24.                 'class' => 'form-control border-0 bg-light px-4'
  25.             ]
  26.         ])
  27.             ->add('subject'TextType::class, [
  28.                 'label' => 'Sujet',
  29.                 'attr' => [
  30.                     'class' => 'form-control border-0 bg-light px-4'
  31.                 ]
  32.     
  33.             ])
  34.             ->add('message'TextType::class, [
  35.                 'label' => 'Votre message',
  36.                 'attr' => [
  37.                     'class' => 'form-control border-0 bg-light px-4'
  38.                 ]
  39.     
  40.             ])
  41.         ;
  42.     }
  43.     public function configureOptions(OptionsResolver $resolver): void
  44.     {
  45.         $resolver->setDefaults([
  46.             'data_class' => Contact::class,
  47.         ]);
  48.     }
  49. }