Added option to "save and clone" a part, which is especially useful, when creatiing multiple similar parts.

This should (partly) fix issue 45.
This commit is contained in:
Jan Böhmer 2020-05-30 23:50:50 +02:00
parent d4818d2fa1
commit 6602015a5a
4 changed files with 26 additions and 2 deletions

View file

@ -180,6 +180,12 @@ class PartController extends AbstractController
$em->persist($part);
$em->flush();
$this->addFlash('info', 'part.edited_flash');
//Redirect to clone page if user wished that...
if ("save_and_clone" === $form->getClickedButton()->getName()) {
return $this->redirectToRoute('part_clone', ['id' => $part->getID()]);
}
//Reload form, so the SIUnitType entries use the new part unit
$form = $this->createForm(PartBaseType::class, $part);
} elseif ($form->isSubmitted() && ! $form->isValid()) {
@ -301,6 +307,11 @@ class PartController extends AbstractController
$em->flush();
$this->addFlash('success', 'part.created_flash');
//Redirect to clone page if user wished that...
if ("save_and_clone" === $form->getClickedButton()->getName()) {
return $this->redirectToRoute('part_clone', ['id' => $new_part->getID()]);
}
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
}