mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Only recreate the BaseAdmin form when the form were valid.
Otherwise we loose the infos about the errors and so can not show them to user.
This commit is contained in:
parent
082a815f3a
commit
03c1d35887
1 changed files with 4 additions and 3 deletions
|
@ -76,13 +76,14 @@ abstract class BaseAdminController extends AbstractController
|
|||
$em->persist($entity);
|
||||
$em->flush();
|
||||
$this->addFlash('success', $this->translator->trans('entity.edit_flash'));
|
||||
|
||||
//Rebuild form, so it is based on the updated data. Important for the parent field!
|
||||
//We can not use dynamic form events here, because the parent entity list is build from database!
|
||||
$form = $this->createForm($this->form_class, $entity);
|
||||
} elseif ($form->isSubmitted() && ! $form->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans('entity.edit_flash.invalid'));
|
||||
}
|
||||
|
||||
//Rebuild form, so it is based on the updated data. Important for the parent field!
|
||||
$form = $this->createForm($this->form_class, $entity);
|
||||
|
||||
return $this->render($this->twig_template, [
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue