rendre modifiable les inscriptions (ref #113)

This commit is contained in:
afornerot 2020-04-06 09:28:52 +02:00
parent e9d13ed100
commit f9df134c46
4 changed files with 42 additions and 20 deletions

View File

@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
(-100, 'DRAAF', '130007107'); (-100, 'DRAAF', '130007107');
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}sh/qcK9rVlrIFTJVhcolNLa3Ww0g4ZzK (-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}Ohb+BjJ5uHPUGP9Xpcl3j1woHkTgkbH0
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple'); ', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');

View File

@ -388,6 +388,18 @@ class RegistrationController extends Controller
// Sur erreur // Sur erreur
$this->getErrorForm($id,$form,$request,$data,"send"); $this->getErrorForm($id,$form,$request,$data,"send");
// Sur validation
if ($form->get('save')->isClicked() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$data = $form->getData();
// Sauvegarde
$em->persist($data);
$em->flush();
return $this->redirectToRoute('cadoles_core_config_registration');
}
// Sur validation // Sur validation
if ($form->get('submit')->isClicked() && $form->isValid()) { if ($form->get('submit')->isClicked() && $form->isValid()) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();

View File

@ -33,11 +33,20 @@ class RegistrationType extends AbstractType
$builder->add('submit', $builder->add('submit',
SubmitType::class, array( SubmitType::class, array(
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"), "label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Confirmer"),
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success")) "attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
) )
); );
if($options["mode"]=="send") {
$builder->add('save',
SubmitType::class, array(
"label" => "Sauvegarder",
"attr" => array("class" => "btn btn-success")
)
);
}
# Obligatoire # Obligatoire
$builder->add('username', $builder->add('username',
TextType::class, array( TextType::class, array(
@ -50,7 +59,7 @@ class RegistrationType extends AbstractType
$builder->add('lastname', $builder->add('lastname',
TextType::class, array( TextType::class, array(
"label" =>"Nom de Famille", "label" =>"Nom de Famille",
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -58,7 +67,7 @@ class RegistrationType extends AbstractType
$builder->add('email', $builder->add('email',
EmailType::class, array( EmailType::class, array(
"label" =>"Mail", "label" =>"Mail",
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -68,8 +77,8 @@ class RegistrationType extends AbstractType
array("class" => "CadolesCoreBundle:Niveau01", array("class" => "CadolesCoreBundle:Niveau01",
"label" => $session->get('labelniveau01'), "label" => $session->get('labelniveau01'),
"choice_label" => "label", "choice_label" => "label",
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="submit"?false:true)))); "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]=="delete"?true:false))));
# Password # Password
if($options["mode"]!="delete"&&$options["mode"]!="send") { if($options["mode"]!="delete"&&$options["mode"]!="send") {
@ -98,7 +107,7 @@ class RegistrationType extends AbstractType
TextType::class, array( TextType::class, array(
"label" =>"Prénom", "label" =>"Prénom",
"required" => (!array_key_exists("firstname",$fields)?false:($fields["firstname"]["perm"]==2)), "required" => (!array_key_exists("firstname",$fields)?false:($fields["firstname"]["perm"]==2)),
"disabled" => ($options["mode"]=="delete"||$options["mode"]=="send"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -110,7 +119,7 @@ class RegistrationType extends AbstractType
ChoiceType::class,array( ChoiceType::class,array(
"label" =>"Visible", "label" =>"Visible",
"required" => (!array_key_exists("visible",$fields)?false:($fields["visible"]["perm"]==2)), "required" => (!array_key_exists("visible",$fields)?false:($fields["visible"]["perm"]==2)),
'disabled' => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"choices" => $choices "choices" => $choices
) )
@ -122,7 +131,7 @@ class RegistrationType extends AbstractType
TextType::class, array( TextType::class, array(
"label" => "Nom d'Usage", "label" => "Nom d'Usage",
"required" => (!array_key_exists("usualname",$fields)?false:($fields["usualname"]["perm"]==2)), "required" => (!array_key_exists("usualname",$fields)?false:($fields["usualname"]["perm"]==2)),
"disabled" => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -133,7 +142,7 @@ class RegistrationType extends AbstractType
TextType::class, array( TextType::class, array(
"label" => "Autre Prénom", "label" => "Autre Prénom",
"required" => (!array_key_exists("givensname",$fields)?false:($fields["givensname"]["perm"]==2)), "required" => (!array_key_exists("givensname",$fields)?false:($fields["givensname"]["perm"]==2)),
"disabled" => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -144,7 +153,7 @@ class RegistrationType extends AbstractType
TextType::class, array( TextType::class, array(
"label" => "Téléphone", "label" => "Téléphone",
"required" => (!array_key_exists("telephonenumber",$fields)?false:($fields["telephonenumber"]["perm"]==2)), "required" => (!array_key_exists("telephonenumber",$fields)?false:($fields["telephonenumber"]["perm"]==2)),
"disabled" => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -155,7 +164,7 @@ class RegistrationType extends AbstractType
TextareaType::class, array( TextareaType::class, array(
"label" => "Adresse", "label" => "Adresse",
"required" => (!array_key_exists("postaladress",$fields)?false:($fields["postaladress"]["perm"]==2)), "required" => (!array_key_exists("postaladress",$fields)?false:($fields["postaladress"]["perm"]==2)),
"disabled" => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height: 90px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px; height: 90px")
) )
); );
@ -166,7 +175,7 @@ class RegistrationType extends AbstractType
DateType::class, array( DateType::class, array(
"label" => "Date de Naissance", "label" => "Date de Naissance",
"required" => (!array_key_exists("birthdate",$fields)?false:($fields["birthdate"]["perm"]==2)), "required" => (!array_key_exists("birthdate",$fields)?false:($fields["birthdate"]["perm"]==2)),
"disabled" => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"widget" => 'single_text', "widget" => 'single_text',
"format" => "dd/MM/yyyy", "format" => "dd/MM/yyyy",
"html5" => false, "html5" => false,
@ -182,7 +191,7 @@ class RegistrationType extends AbstractType
ChoiceType::class,array( ChoiceType::class,array(
"label" =>"Sexe", "label" =>"Sexe",
"required" => (!array_key_exists("gender",$fields)?false:($fields["gender"]["perm"]==2)), "required" => (!array_key_exists("gender",$fields)?false:($fields["gender"]["perm"]==2)),
'disabled' => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"), "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
"choices" => $choices "choices" => $choices
) )
@ -194,7 +203,7 @@ class RegistrationType extends AbstractType
TextType::class, array( TextType::class, array(
"label" => "Métier", "label" => "Métier",
"required" => (!array_key_exists("job",$fields)?false:($fields["job"]["perm"]==2)), "required" => (!array_key_exists("job",$fields)?false:($fields["job"]["perm"]==2)),
"disabled" => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -205,7 +214,7 @@ class RegistrationType extends AbstractType
TextType::class, array( TextType::class, array(
"label" => "Fonction", "label" => "Fonction",
"required" => (!array_key_exists("position",$fields)?false:($fields["position"]["perm"]==2)), "required" => (!array_key_exists("position",$fields)?false:($fields["position"]["perm"]==2)),
"disabled" => ($options["mode"]=="submit"?false:true), "disabled" => ($options["mode"]=="delete"?true:false),
"attr" => array("class" => "form-control", "style" => "margin-bottom:15px") "attr" => array("class" => "form-control", "style" => "margin-bottom:15px")
) )
); );
@ -216,7 +225,7 @@ class RegistrationType extends AbstractType
$builder->add('birthcountry', $builder->add('birthcountry',
Select2EntityType::class, array( Select2EntityType::class, array(
'label' => "Pays de Naissance", 'label' => "Pays de Naissance",
'disabled' => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"required" => (!array_key_exists("birthcountry",$fields)?false:($fields["birthcountry"]["perm"]==2)), "required" => (!array_key_exists("birthcountry",$fields)?false:($fields["birthcountry"]["perm"]==2)),
'multiple' => false, 'multiple' => false,
'remote_route' => 'cadoles_core_ajax_country_list', 'remote_route' => 'cadoles_core_ajax_country_list',
@ -240,7 +249,7 @@ class RegistrationType extends AbstractType
$builder->add('birthplace', $builder->add('birthplace',
Select2EntityType::class, array( Select2EntityType::class, array(
'label' => "Ville de Naissance", 'label' => "Ville de Naissance",
'disabled' => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"required" => false, "required" => false,
'multiple' => false, 'multiple' => false,
'remote_route' => 'cadoles_core_ajax_city_list', 'remote_route' => 'cadoles_core_ajax_city_list',
@ -265,7 +274,7 @@ class RegistrationType extends AbstractType
$builder->add('niveau02', $builder->add('niveau02',
Select2EntityType::class, array( Select2EntityType::class, array(
'label' => $session->get('labelniveau02'), 'label' => $session->get('labelniveau02'),
'disabled' => ($options["mode"]=="delete"?true:false), "disabled" => ($options["mode"]=="delete"?true:false),
"required" => (!array_key_exists("niveau02",$fields)?false:($fields["niveau02"]["perm"]==2)), "required" => (!array_key_exists("niveau02",$fields)?false:($fields["niveau02"]["perm"]==2)),
'multiple' => false, 'multiple' => false,
'remote_route' => 'cadoles_core_ajax_niveau02_list', 'remote_route' => 'cadoles_core_ajax_niveau02_list',

View File

@ -21,6 +21,7 @@
{% endif %} {% endif %}
{% if mode!="submit" %} {% if mode!="submit" %}
{{ form_widget(form.save) }}
<a class="btn btn-default" href={{ path('cadoles_core_config_registration') }}>Annuler</a> <a class="btn btn-default" href={{ path('cadoles_core_config_registration') }}>Annuler</a>
{% endif %} {% endif %}