<?php
namespace App\Form;
use App\Entity\Sessions;
use App\Entity\Inscriptionpersos;
use App\Repository\SessionsRepository;
use Symfony\Component\Form\AbstractType;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
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;
use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
class InscriptionCertyouFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$certificat = $options['certyou'];
$builder
->add('choix', TextType::class, [
'required' => false,
'mapped' => false,
'disabled' => true,
'attr' => [
'class' => 'form-control',
'readonly' => true,
],
'label' => 'Type de formation séléctionnée'])
->add('types', ChoiceType::class, [
'required' => false,
'mapped' => false,
'attr' => [
'class' => 'form-control',
'readonly' => true,
],
'placeholder' => 'Choisi du type',
'choices' => [
'classe virtuelle' => 'virtuelle',
'classe présentielle + virtuelle' => 'presentiel',
],
'label' => 'Choix du type de formation <span style="color:red">*</span>',
'label_html' => true,])
->add('duree', TextType::class, [
'required' => false,
'mapped' => false,
'disabled' => true,
'attr' => [
'class' => 'form-control',
'readonly' => true,
],
'label' => 'Durée de la formation <span style="color:red">*</span>',
'label_html' => true,])
->add('session', EntityType::class, [
'class' =>Sessions::class,
'required' => true,
'mapped' => false,
// FILTRAGE PAR CERTIFICAT
'query_builder' => function (SessionsRepository $sr) use ($certificat) {
return $sr->createQueryBuilder('s')
->andWhere('s.certyou = :certificat')
->setParameter('certificat', $certificat)
->orderBy('s.session', 'ASC');
},
// AFFICHAGE DE LA DATE
'choice_label' => function (Sessions $session) {
return $session->getSession();
},
'attr' => [
'class' => 'form-control',
],
'label' => 'Date de la session de formation <span style="color:red">*</span>',
'label_html' => true,])
->add('lieu', ChoiceType::class, [
'required' => true,
'mapped' => false,
'attr' => [
'class' => 'form-control',
'readonly' => true,
],
'choices' => [
'abidjan' => 'ABIDJAN',
'dakar' => 'DAKAR',
'casablanca' => 'CASABLANCA',
'paris' => 'PARIS',
],
'label' => 'Choix du lieu de la formation <span style="color:red">*</span>',
'label_html' => true,])
->add('prixvirtuelle', TextType::class, [
'required' => true,
'mapped' => false,
'disabled' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
'readonly' => true,
'minlenght' => '2',
'maxlenght' => '100'
],
'label' => 'Prix classe(uniquement virtuelle) <span style="color:red">*</span>',
'label_html' => true,])
->add('prixpresentiel', TextType::class, [
'required' => true,
'mapped' => false,
'disabled' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
'readonly' => true,
'minlenght' => '2',
'maxlenght' => '100'
],
'label' => 'Prix classe(virtuelle + présentielle) <span style="color:red">*</span>',
'label_html' => true,])
->add('civilite', ChoiceType::class, [
'required' => true,
'mapped' => false,
'attr' => [
'class' => 'form-control',
],
'choices' => [
// 'choix du rôle de l\'utilisateur' => 'choix',
'Monsieur' => 'M.',
'Madame' => 'Mme',
'Mademoiselle' => 'Mselle',
],
'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','placeholder' => "Ex: +225 0708971405",
'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',
'label_html' => true,])
->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' => true,
'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','placeholder' => "Ex: +225 0708971405",
],
'label_html' => true,
'label' => 'Whatsapp <span style="color:red">*</span>'])
->add('adresse', TextType::class, [
'required' => true,
'attr' => [
'class' => 'form-control mt-1 mb-1',
],
'label' => 'Adresse <span style="color:red">*</span>',
'label_html' => true,])
->add('commentaire', TextareaType::class, [
'required' => false,
'attr' => [
'class' => 'form-control textarea',
],
'label' => 'Commentaire',
'label_html' => true,])
->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' => 'Envoyer']);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => null,
'certyou' => null,
]);
}
}