src/Form/ContactType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Model\ContactModel;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  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.                     'data-type' => "nom"
  19.                 ]
  20.             ])
  21.             ->add('firstName'TextType::class, [
  22.                 'label' => 'Prénom*',
  23.                 'attr' => [
  24.                     'data-type' => "prenom"
  25.                 ]
  26.             ])
  27.             ->add('street'TextType::class, [
  28.                 'label' => 'Rue*',
  29.                 'attr' => [
  30.                     'data-type' => "rue"
  31.                 ]
  32.             ])
  33.             ->add('postalCode'TextType::class, [
  34.                 'label' => 'Code postal*',
  35.                 'attr' => [
  36.                     'data-type' => "code_postal"
  37.                 ]
  38.             ])
  39.             ->add('city'TextType::class, [
  40.                 'label' => 'Ville*',
  41.                 'attr' => [
  42.                     'data-type' => "ville"
  43.                 ]
  44.             ])
  45.             ->add('email'EmailType::class, [
  46.                 'label' => 'Email*',
  47.                 'attr' => [
  48.                     'data-type' => "email"
  49.                 ]
  50.             ])
  51.             ->add('telephone'TextType::class, [
  52.                 'label' => 'Téléphone*',
  53.                 'attr' => [
  54.                     'data-type' => "phone"
  55.                 ]
  56.             ])
  57.             ->add('message'TextareaType::class, [
  58.                 'label' => 'Pour quelle raison bous solicitez-vous ?*',
  59.             ]);
  60.     }
  61.     public function configureOptions(OptionsResolver $resolver): void
  62.     {
  63.         $resolver->setDefaults([
  64.             'data_class' => ContactModel::class
  65.         ]);
  66.     }
  67. }