src/Form/ContactType.php line 14

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\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\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  11. class ContactType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options): void
  14.     {
  15.         $builder
  16.             ->add('civilite'ChoiceType::class, [
  17.                 "attr" => array (
  18.                     "class" => "form-control",
  19.                     'required'   => true,
  20.                 ),
  21.                 'choices' => [
  22.                     'Mademoiselle' => 'Mademoiselle',
  23.                     'Madame' => 'Madame',
  24.                     'Monsieur' => 'Monsieur',
  25.                 ],
  26.             ])
  27.             ->add('nom'TextType::class, [
  28.                 "attr" => array (
  29.                     "class" => "form-control",
  30.                     'required'   => true,
  31.                 )
  32.             ])
  33.             ->add('email'EmailType::class, [
  34.                 "attr" => array (
  35.                     "class" => "form-control",
  36.                     'required'   => true,
  37.                 )
  38.             ])
  39.             ->add('telephone'TextType::class, [
  40.                 "attr" => array (
  41.                     "class" => "form-control",
  42.                     'required'   => true,
  43.                 )
  44.             ])
  45.             ->add('objet'TextType::class, [
  46.                 "attr" => array (
  47.                     "class" => "form-control",
  48.                     'required'   => true,
  49.                 )
  50.             ])
  51.             ->add('message'TextareaType::class, [
  52.                 "attr" => array (
  53.                     "class" => "form-control",
  54.                     'required'   => true,
  55.                 )
  56.             ])
  57.             ->add('requete'ChoiceType::class, [
  58.                 "attr" => array (
  59.                     'required'   => true,
  60.                 ),
  61.                 'choices' => [
  62.                     'Recontactez-moi' => 'Recontactez-moi',
  63.                     'Demande de documentation' => 'Demande de documentation',
  64.                 ],
  65.                 'expanded' => true
  66.             ])
  67.         ;
  68.     }
  69.     public function configureOptions(OptionsResolver $resolver): void
  70.     {
  71.         $resolver->setDefaults([
  72.             'data_class' => Contact::class,
  73.         ]);
  74.     }
  75. }