mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
admin: fix new document category
This commit is contained in:
parent
f4652adbc2
commit
b7ed658f96
@ -102,10 +102,18 @@ class DocumentCategoryController extends AbstractController
|
||||
public function new(Request $request): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$nextId = $em
|
||||
->createQuery(
|
||||
'SELECT MAX(c.idInsideBundle) + 1 FROM ChillDocStoreBundle:DocumentCategory c'
|
||||
)
|
||||
->getSingleResult();
|
||||
|
||||
$documentCategory = new DocumentCategory(
|
||||
ChillDocStoreBundle::class,
|
||||
$em->getRepository(DocumentCategory::class)->nextIdInsideBundle()
|
||||
reset($nextId)
|
||||
);
|
||||
|
||||
$documentCategory
|
||||
->setDocumentClass(PersonDocument::class);
|
||||
|
||||
@ -120,8 +128,6 @@ class DocumentCategoryController extends AbstractController
|
||||
return $this->redirectToRoute('document_category_index');
|
||||
}
|
||||
|
||||
$documentCategory->setBundleId(ChillDocStoreBundle::class);
|
||||
|
||||
return $this->render('ChillDocStoreBundle:DocumentCategory:new.html.twig', [
|
||||
'document_category' => $documentCategory,
|
||||
'form' => $form->createView(),
|
||||
|
@ -37,13 +37,13 @@ class DocumentCategoryType extends AbstractType
|
||||
$builder
|
||||
->add('bundleId', ChoiceType::class, [
|
||||
'choices' => $this->chillBundlesFlipped,
|
||||
'disabled' => true,
|
||||
'disabled' => false,
|
||||
])
|
||||
->add('idInsideBundle', null, [
|
||||
'disabled' => true,
|
||||
])
|
||||
->add('documentClass', null, [
|
||||
'disabled' => true,
|
||||
'disabled' => false,
|
||||
]) // cahcerh par default PersonDocument
|
||||
->add('name', TranslatableStringFormType::class);
|
||||
}
|
||||
|
@ -61,15 +61,4 @@ class DocumentCategoryRepository implements ObjectRepository
|
||||
{
|
||||
return DocumentCategory::class;
|
||||
}
|
||||
|
||||
public function nextIdInsideBundle()
|
||||
{
|
||||
$array_res = $this->em
|
||||
->createQuery(
|
||||
'SELECT MAX(c.idInsideBundle) + 1 FROM ChillDocStoreBundle:DocumentCategory c'
|
||||
)
|
||||
->getSingleResult();
|
||||
|
||||
return reset($array_res);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user