<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use App\Repository\paysRepository;
use App\Entity\pays;
class compteType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('civilite', ChoiceType::class, [
'translation_domain' => 'form',
'choice_translation_domain' => 'form',
'label' => false, //'compte.register.civilite.label',
'required' => true,
'placeholder' => false,
'choices' => [
'compte.register.civilite.choix.madame.label' => 1,
'compte.register.civilite.choix.monsieur.label' => 0
],
'multiple' => false,
'expanded' => true
])
->add('nom', TextType::class, [
'translation_domain' => 'form',
'label' => 'compte.register.nom.label',
'attr' => ['class' => 'form-control'],
'required' => true
])
->add('prenom', TextType::class, [
'translation_domain' => 'form',
'label' => "compte.register.prenom.label",
'attr' => ['class' => 'form-control'],
'required' => true
])
->add('email', EmailType::class, [
'translation_domain' => 'form',
'label' => "compte.register.email.label",
'attr' => ['class' => 'form-control'],
'required' => true
])
->add('tel', TextType::class, [
'translation_domain' => 'form',
'label' => "compte.register.telephone.label",
'attr' => ['class' => 'form-control'],
'required' => true
])
->add('password', RepeatedType::class, [
'translation_domain' => 'form',
'required' => true,
'attr' => ['class' => 'form-control'],
'type' => PasswordType::class,
'invalid_message' => 'The password fields must match.',
'options' => ['attr' => ['class' => 'form-control']],
'first_options' =>['label' => 'compte.register.password.first.label'],
'second_options' => ['label' => 'compte.register.password.second.label']
])
->add('adresse', TextType::class, [
'translation_domain' => 'form',
'label' => 'compte.register.adresse.ligne1.label',
'attr' => ['class' => 'form-control'],
'required' => true
])
->add('complementadresse', TextType::class, [
'translation_domain' => 'form',
'required' => false,
'label' => 'compte.register.adresse.ligne2.label',
'attr' => ['class' => 'form-control']
])
->add('cp', IntegerType::class, [
'translation_domain' => 'form',
'label' => 'compte.register.adresse.cp.label',
'attr' => ['class' => 'form-control'],
'required' => true
])
->add('ville', TextType::class, [
'translation_domain' => 'form',
'label' => 'compte.register.adresse.ville.label',
'attr' => ['class' => 'form-control'],
'required' => true
])
->add('pays', EntityType::class, [
'translation_domain' => 'form',
'label' => 'compte.register.adresse.pays.label',
'class' => pays::class,
'attr' => ['class' => 'form-control'],
'query_builder' => function (paysRepository $er) {
return $er->createQueryBuilder('p')
->where('p.etat = 1');
},
'choice_label' => 'nom'
])
->add('optin', ChoiceType::class, [
'translation_domain' => 'form',
"label" => 'compte.register.optin.label',
"choices" => ["oui" => 1, "non" => 0],
'choice_translation_domain' => 'global',
'multiple' => false,
'expanded' => true,
])
;
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'App\Entity\compte'
]);
}
}