mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix saving person
This commit is contained in:
parent
ec6828f128
commit
9247cd3546
@ -150,7 +150,7 @@ final class PersonController extends AbstractController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editAction($person_id)
|
public function editAction($person_id, Request $request)
|
||||||
{
|
{
|
||||||
$person = $this->_getPerson($person_id);
|
$person = $this->_getPerson($person_id);
|
||||||
|
|
||||||
@ -163,57 +163,33 @@ final class PersonController extends AbstractController
|
|||||||
|
|
||||||
$form = $this->createForm(PersonType::class, $person,
|
$form = $this->createForm(PersonType::class, $person,
|
||||||
array(
|
array(
|
||||||
"action" => $this->generateUrl('chill_person_general_update',
|
|
||||||
array("person_id" => $person_id)),
|
|
||||||
"cFGroup" => $this->getCFGroup()
|
"cFGroup" => $this->getCFGroup()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:Person:edit.html.twig',
|
$form->handleRequest($request);
|
||||||
array('person' => $person, 'form' => $form->createView()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateAction($person_id, Request $request)
|
|
||||||
{
|
|
||||||
$person = $this->_getPerson($person_id);
|
|
||||||
|
|
||||||
if ($person === null) {
|
|
||||||
return $this->createNotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_UPDATE', $person,
|
|
||||||
'You are not allowed to edit this person');
|
|
||||||
|
|
||||||
$form = $this->createForm(PersonType::class, $person,
|
|
||||||
array("cFGroup" => $this->getCFGroup()));
|
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ( ! $form->isValid() ) {
|
|
||||||
$this->get('session')
|
|
||||||
->getFlashBag()->add('error', $this->translator
|
|
||||||
->trans('This form contains errors'));
|
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:Person:edit.html.twig',
|
|
||||||
array('person' => $person,
|
|
||||||
'form' => $form->createView()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && !$form->isValid()) {
|
||||||
|
$this->get('session')
|
||||||
|
->getFlashBag()->add('error', $this->translator
|
||||||
|
->trans('This form contains errors'));
|
||||||
|
} elseif ($form->isSubmitted() && $form->isValid()) {
|
||||||
$this->get('session')->getFlashBag()
|
$this->get('session')->getFlashBag()
|
||||||
->add('success',
|
->add('success',
|
||||||
$this->get('translator')
|
$this->get('translator')
|
||||||
->trans('The person data has been updated')
|
->trans('The person data has been updated')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
$url = $this->generateUrl('chill_person_view', array(
|
return $this->redirectToRoute('chill_person_view', [
|
||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
));
|
]);
|
||||||
|
|
||||||
return $this->redirect($url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $this->render('ChillPersonBundle:Person:edit.html.twig',
|
||||||
|
array('person' => $person, 'form' => $form->createView()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user