src/Form/ContactType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Contact;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  6. use Symfony\Component\Form\Extension\Core\Type\TextType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Validator\Constraints\Email;
  10. class ContactType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('fullName',TextType::class,[
  16.                 'label'=>false,
  17.                 'attr'=>[
  18.                     'class'=>"form-control",
  19.                     'id'=>'name',
  20.                     'placeholder'=>'Votre nom'
  21.                 ]
  22.             ])
  23.             ->add('email'\Symfony\Component\Form\Extension\Core\Type\EmailType::class, [
  24.                 'label'=>false,
  25.                 'attr'=>[
  26.                     'class'=>"form-control",
  27.                     'id'=>'email',
  28.                     'placeholder'=>'Votre Email'
  29.                 ]
  30.             ])
  31.             ->add('subject',TextType::class,[
  32.                 'label'=>false,
  33.                 'attr'=>[
  34.                     'class'=>"form-control",
  35.                     'id'=>'subjet',
  36.                     'placeholder'=>'Objet'
  37.                 ]
  38.             ])
  39.             ->add('message'TextareaType::class,[
  40.                 'label'=>false,
  41.                 'attr'=>[
  42.                     'class'=>"form-control",
  43.                     'id'=>'message',
  44.                     'placeholder'=>'Votre message'
  45.                 ]
  46.             ])
  47.         ;
  48.     }
  49.     public function configureOptions(OptionsResolver $resolver): void
  50.     {
  51.         $resolver->setDefaults([
  52.             'data_class' => Contact::class,
  53.         ]);
  54.     }
  55. }