Added possibility to save parts and create an empty one

This commit is contained in:
Jan Böhmer 2023-02-05 21:00:26 +01:00
parent 13de2afc28
commit c088742dda
6 changed files with 1142 additions and 1120 deletions

View file

@ -162,13 +162,17 @@ class PartController extends AbstractController
$em->persist($part);
$em->flush();
$this->addFlash('info', 'part.edited_flash');
$this->addFlash('success', 'part.edited_flash');
//Redirect to clone page if user wished that...
//@phpstan-ignore-next-line
if ('save_and_clone' === $form->getClickedButton()->getName()) {
return $this->redirectToRoute('part_clone', ['id' => $part->getID()]);
}
//@phpstan-ignore-next-line
if ('save_and_new' === $form->getClickedButton()->getName()) {
return $this->redirectToRoute('part_new');
}
//Reload form, so the SIUnitType entries use the new part unit
$form = $this->createForm(PartBaseType::class, $part);
@ -310,6 +314,10 @@ class PartController extends AbstractController
if ('save_and_clone' === $form->getClickedButton()->getName()) {
return $this->redirectToRoute('part_clone', ['id' => $new_part->getID()]);
}
//@phpstan-ignore-next-line
if ('save_and_new' === $form->getClickedButton()->getName()) {
return $this->redirectToRoute('part_new');
}
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
}