<?php
namespace App\Form;
use App\Entity\Thematiques;
use App\Entity\Themes;
use App\Entity\Villes;
use App\Entity\Inscriptionpersos ;
use Symfony\Component\Form\AbstractType;
use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
class NewInscriptionFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('civilite', ChoiceType::class, [
'mapped' => false,
'attr' => [
'class' => 'form-control',
],
'choices' => [
// 'choix du rôle de l\'utilisateur' => 'choix',
'M.' => 'Monsieur',
'Mme' => 'Madame',
'Mselle' => 'Mademoiselle',
],
'label' => 'Civilité <span style="color:red">*</span>',
'label_html' => true,])
->add('nom', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control',
],
'label' => 'Nom <span style="color:red">*</span>',
'label_html' => true])
->add('prenoms', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
'minlenght' => '2',
'maxlenght' => '100'
],
'label' => 'Prénoms <span style="color:red">*</span>',
'label_html' => true])
->add('fonction', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
'minlenght' => '2',
'maxlenght' => '100'
],
'label' => 'Fonction <span style="color:red">*</span>',
'label_html' => true])
->add('telephone', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
'minlenght' => '2',
'maxlenght' => '100'
],
'label' => 'Téléphone<span style="color:red">*</span>',
'label_html' => true])
->add('mail', EmailType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
'minlenght' => '2',
'maxlenght' => '100'
],
'label' => 'Adresse email <span style="color:red">*</span>',
'label_html' => true])
->add('entreprise', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => 'Entreprise ou Projet de Financement <span style="color:red">*</span>',
'label_html' => true])
->add('siteweb', UrlType::class, [
'required' => false,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => "Site Web de votre Entreprise"])
->add('nbparticipant', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => 'Nombre de participants <span style="color:red">*</span>',
'label_html' => true])
->add('pays', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => 'Pays <span style="color:red">*</span>',
'label_html' => true])
->add('ville', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => 'Ville <span style="color:red">*</span>',
'label_html' => true])
->add('boitepostale', TextType::class, [
'required' => false,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => "Boite postale"])
->add('whatsapp', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => 'Whatsapp <span style="color:red">*</span>',
'label_html' => true])
->add('adresse', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => "Adresse"])
->add('thematique', EntityType::class, [
'class' => Thematiques::class,
'choice_label' => 'nom',
'placeholder' => 'Sélectionner la thématique', // â
ici
'required' => true,
'mapped' => false,
'attr' => [
'class' => 'form-control border-2 mt-1 mb-1 select2'
],
'label' => false
])
->add('theme', EntityType::class, [
'required' => true,
'mapped' => true,
'attr' => [
'class' => 'form-control border-2 mt-1 mb-1 select2',
],
'class' => Themes::class,
'placeholder' => 'Selectionner une thème',
'choice_label' => 'nom',
'label' => false,
])
->add('lieu', EntityType::class, [
'required' => true,
'mapped' => true,
'attr' => [
'class' => 'form-control border-2 mt-1 mb-1 select2',
],
'class' => Villes::class,
'choices' => $options['lieux'],
'placeholder' => 'Selectionner le lieu',
'choice_label' => 'nom',
'label' => false,])
->add('prix', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1','placeholder' => 'Prix',
],
'label' => false])
->add('periode', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1','placeholder' => 'Période',
],
'label' => false])
->add('commentaire', TextareaType::class, [
'required' => true,
'attr' => [
'class' => 'form-control textarea',
],
'label' => "Commentaire"])
->add('captcha', Recaptcha3Type::class, [
'constraints' => new Recaptcha3(),
'action_name' => 'contact',
'constraints' => new Recaptcha3 ([
'message' => 'karser_recaptcha3.message',
'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
]),
])
->add('submit', SubmitType::class, [
'attr' => [
'class' => 'btn btn-primary btn-large',
'style' => 'font-family: arial'
],
'label' => 'Enregistrer']);
// ...
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Inscriptionpersos::class,
'lieux' => [], // <-- déclaration de l'option personnalisée
]);
}
}