mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 09:53:35 +02:00
Use /part/new route for creating a new part, and allow to use cid GET param to specify the category in which the part should be created.
This commit is contained in:
parent
218eec874d
commit
c037a76651
1 changed files with 7 additions and 4 deletions
|
@ -50,7 +50,7 @@ class PartController extends AbstractController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/part/{id}/info", name="part_info")
|
* @Route("/part/{id}/info", name="part_info")
|
||||||
* @Route("/part/{id}")
|
* @Route("/part/{id}", requirements={"id"="\d+"})
|
||||||
*/
|
*/
|
||||||
public function show(Part $part, AttachmentFilenameService $attachmentFilenameService)
|
public function show(Part $part, AttachmentFilenameService $attachmentFilenameService)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ class PartController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/part/{id}/edit", name="part_edit", requirements={"id"="\d+"})
|
* @Route("/part/{id}/edit", name="part_edit")
|
||||||
*
|
*
|
||||||
* @param Part $part
|
* @param Part $part
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
@ -90,14 +90,17 @@ class PartController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/parts/new", name="part_new")
|
* @Route("/part/new", name="part_new")
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator)
|
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$new_part = new Part();
|
$new_part = new Part();
|
||||||
$category = $em->find(Category::class, 1);
|
|
||||||
|
$cid = $request->get('cid', 1);
|
||||||
|
|
||||||
|
$category = $em->find(Category::class, $cid);
|
||||||
$new_part->setCategory($category);
|
$new_part->setCategory($category);
|
||||||
|
|
||||||
$form = $this->createForm(PartType::class, $new_part);
|
$form = $this->createForm(PartType::class, $new_part);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue