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\Extension\Core\Type\ChoiceType;
  6. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  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. class ContactType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options)
  14.     {
  15.         $builder
  16.             ->add('firstname'TextType::class ,[
  17.                 "label" => "Prénom*",
  18.                 "attr" => [
  19.                     'class' => "form-control",
  20.                 ]
  21.             ])
  22.             ->add('lastname'TextType::class,[
  23.                 "label" => "Nom*",
  24.                 "attr" => [
  25.                     'class' => "form-control",
  26.                 ]
  27.             ])
  28.             ->add('email'TextType::class,[
  29.                 "label" => "Email*",
  30.                 "attr" => [
  31.                     'class' => "form-control",
  32.                 ]
  33.             ])
  34.             ->add('phoneNumber'TextType::class,[
  35.                 "label" => "Téléphone*",
  36.                 "attr" => [
  37.                     'class' => "form-control",
  38.                 ]
  39.             ])
  40.             ->add('subject'ChoiceType::class,[
  41.                 "label" => "Objet*",
  42.                 'choices' => [
  43.                     'Demande de devis' => "Demande de devis",
  44.                     'Demande d’informations' => "Demande d’informations",
  45.                     'Autres demandes' => "Autres demandes",
  46.                 ],
  47.                 "attr" => [
  48.                     'class' => "form-control",
  49.                 ]
  50.             ])
  51.             ->add('message'TextareaType::class,[
  52.                 "label" => "Message*",
  53.                 "attr" => [
  54.                     "rows" => 5,
  55.                     "class" => "form-control",
  56.                 ],
  57.             ])
  58.             ->add('contactFiles'CollectionType::class, array(
  59.                 'entry_type' => ContactFileFormType::class,
  60.                 'entry_options' => array('label' => false),
  61.                 'allow_add' => true,
  62.                 'by_reference' => false,
  63.                 'allow_delete' => true,
  64.                 "label" => false,
  65.                 //'by_reference' => false,
  66.             ));
  67.     }
  68.     public function configureOptions(OptionsResolver $resolver)
  69.     {
  70.         $resolver->setDefaults([
  71.             'data_class' => Contact::class,
  72.         ]);
  73.     }
  74. }