265 lines
11 KiB
PHP
265 lines
11 KiB
PHP
<?php
|
|
namespace Cadoles\CoreBundle\Form;
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Component\HttpFoundation\Session\Session;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use Gregwar\CaptchaBundle\Type\CaptchaType;
|
|
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
|
|
|
use Doctrine\ORM\EntityRepository;
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
class RegistrationType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$session = new Session();
|
|
|
|
$builder->add('submit',
|
|
SubmitType::class, array(
|
|
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
|
|
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
|
|
)
|
|
);
|
|
|
|
# Obligatoire
|
|
$builder->add('username',
|
|
TextType::class, array(
|
|
"label" =>"Login",
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('firstname',
|
|
TextType::class, array(
|
|
"label" =>"Prénom",
|
|
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('lastname',
|
|
TextType::class, array(
|
|
"label" =>"Nom de Famille",
|
|
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('email',
|
|
EmailType::class, array(
|
|
"label" =>"Mail",
|
|
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$choices=array("oui" => "1","non" => "0");
|
|
$builder->add("visible",
|
|
ChoiceType::class,array(
|
|
"label" =>"Visible",
|
|
'disabled' => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
|
|
"choices" => $choices
|
|
)
|
|
);
|
|
|
|
|
|
$builder->add('niveau01',
|
|
EntityType::class,
|
|
array("class" => "CadolesCoreBundle:Niveau01",
|
|
"label" => $session->get('labelniveau01'),
|
|
"choice_label" => "label",
|
|
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="submit"?false:true))));
|
|
|
|
# Password
|
|
if($options["mode"]!="delete"&&$options["mode"]!="send") {
|
|
$builder->add('password',
|
|
RepeatedType::class, array(
|
|
"type" => PasswordType::class,
|
|
"required" => ($options["mode"]=="submit"?true:false),
|
|
"first_options" => array("label" => "Mot de Passe","attr" => array("class" => "form-control", "style" => "margin-bottom:15px")),
|
|
"second_options" => array('label' => 'Confirmer Mot de Passe',"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"))
|
|
)
|
|
);
|
|
|
|
$builder->add('captcha',
|
|
CaptchaType::class,array(
|
|
"width" => 200,
|
|
"height" => 50,
|
|
"length" => 6,
|
|
)
|
|
);
|
|
}
|
|
|
|
# Optionnel
|
|
$builder->add('usualname',
|
|
TextType::class, array(
|
|
"label" => "Nom d'Usage",
|
|
"required" => false,
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('givensname',
|
|
TextType::class, array(
|
|
"label" => "Autre Prénom",
|
|
"required" => false,
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('telephonenumber',
|
|
TextType::class, array(
|
|
"label" => "Téléphone",
|
|
"required" => false,
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('postaladress',
|
|
TextareaType::class, array(
|
|
"label" => "Adresse",
|
|
"required" => false,
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height: 90px")
|
|
)
|
|
);
|
|
|
|
$builder->add('birthdate',
|
|
DateType::class, array(
|
|
"label" => "Date de Naissance",
|
|
"required" => false,
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"widget" => 'single_text',
|
|
"format" => "dd/MM/yyyy",
|
|
"html5" => false,
|
|
"attr" => array("class" => "form-control js-datepicker", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false)
|
|
)
|
|
)
|
|
);
|
|
|
|
$choices=array("" => "", "homme" => "male","femme" => "female");
|
|
$builder->add("gender",
|
|
ChoiceType::class,array(
|
|
"label" =>"Sexe",
|
|
"required" => false,
|
|
'disabled' => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
|
|
"choices" => $choices
|
|
)
|
|
);
|
|
|
|
$builder->add('job',
|
|
TextType::class, array(
|
|
"label" => "Métier",
|
|
"required" => false,
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('position',
|
|
TextType::class, array(
|
|
"label" => "Fonction",
|
|
"required" => false,
|
|
"disabled" => ($options["mode"]=="submit"?false:true),
|
|
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
|
|
$builder->add('birthcountry',
|
|
Select2EntityType::class, array(
|
|
'label' => "Pays de Naissance",
|
|
'disabled' => ($options["mode"]=="submit"?false:true),
|
|
'multiple' => false,
|
|
'remote_route' => 'cadoles_core_ajax_country_list',
|
|
'class' => 'Cadoles\coreBundle\Entity\Country',
|
|
'primary_key' => 'id',
|
|
'text_property' => 'label',
|
|
'minimum_input_length' => 2,
|
|
'page_limit' => 10,
|
|
'allow_clear' => true,
|
|
'delay' => 250,
|
|
'cache' => false,
|
|
'cache_timeout' => 60000, // if 'cache' is true
|
|
'language' => 'fr',
|
|
'placeholder' => 'Selectionner un pays',
|
|
'attr' => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('birthplace',
|
|
Select2EntityType::class, array(
|
|
'label' => "Ville de Naissance",
|
|
'disabled' => ($options["mode"]=="submit"?false:true),
|
|
'multiple' => false,
|
|
'remote_route' => 'cadoles_core_ajax_city_list',
|
|
'class' => 'Cadoles\coreBundle\Entity\City',
|
|
'primary_key' => 'id',
|
|
'text_property' => 'label',
|
|
'minimum_input_length' => 2,
|
|
'page_limit' => 10,
|
|
'allow_clear' => true,
|
|
'delay' => 250,
|
|
'cache' => false,
|
|
'cache_timeout' => 60000, // if 'cache' is true
|
|
'language' => 'fr',
|
|
'placeholder' => 'Selectionner une ville',
|
|
'attr' => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
$builder->add('niveau02',
|
|
Select2EntityType::class, array(
|
|
'label' => $session->get('labelniveau02'),
|
|
'disabled' => ($options["mode"]=="submit"?false:true),
|
|
'multiple' => false,
|
|
'remote_route' => 'cadoles_core_ajax_niveau02_list',
|
|
'class' => 'Cadoles\coreBundle\Entity\Niveau02',
|
|
'req_params' => ['niveau01' => 'parent.children[niveau01]'],
|
|
'primary_key' => 'id',
|
|
'text_property' => 'label',
|
|
'minimum_input_length' => 0,
|
|
'page_limit' => 10,
|
|
'allow_clear' => true,
|
|
'delay' => 250,
|
|
'cache' => false,
|
|
'cache_timeout' => 60000, // if 'cache' is true
|
|
'language' => 'fr',
|
|
'placeholder' => 'Selectionner une Localisation',
|
|
'attr' => array("class" => "form-control", "style" => "margin-bottom:15px")
|
|
)
|
|
);
|
|
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults(array(
|
|
'data_class' => 'Cadoles\CoreBundle\Entity\Registration',
|
|
'mode' => "string"
|
|
));
|
|
}
|
|
}
|