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
|
public function new(Request $request): Response
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$nextId = $em
|
||||||
|
->createQuery(
|
||||||
|
'SELECT MAX(c.idInsideBundle) + 1 FROM ChillDocStoreBundle:DocumentCategory c'
|
||||||
|
)
|
||||||
|
->getSingleResult();
|
||||||
|
|
||||||
$documentCategory = new DocumentCategory(
|
$documentCategory = new DocumentCategory(
|
||||||
ChillDocStoreBundle::class,
|
ChillDocStoreBundle::class,
|
||||||
$em->getRepository(DocumentCategory::class)->nextIdInsideBundle()
|
reset($nextId)
|
||||||
);
|
);
|
||||||
|
|
||||||
$documentCategory
|
$documentCategory
|
||||||
->setDocumentClass(PersonDocument::class);
|
->setDocumentClass(PersonDocument::class);
|
||||||
|
|
||||||
@ -120,8 +128,6 @@ class DocumentCategoryController extends AbstractController
|
|||||||
return $this->redirectToRoute('document_category_index');
|
return $this->redirectToRoute('document_category_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
$documentCategory->setBundleId(ChillDocStoreBundle::class);
|
|
||||||
|
|
||||||
return $this->render('ChillDocStoreBundle:DocumentCategory:new.html.twig', [
|
return $this->render('ChillDocStoreBundle:DocumentCategory:new.html.twig', [
|
||||||
'document_category' => $documentCategory,
|
'document_category' => $documentCategory,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
|
@ -37,13 +37,13 @@ class DocumentCategoryType extends AbstractType
|
|||||||
$builder
|
$builder
|
||||||
->add('bundleId', ChoiceType::class, [
|
->add('bundleId', ChoiceType::class, [
|
||||||
'choices' => $this->chillBundlesFlipped,
|
'choices' => $this->chillBundlesFlipped,
|
||||||
'disabled' => true,
|
'disabled' => false,
|
||||||
])
|
])
|
||||||
->add('idInsideBundle', null, [
|
->add('idInsideBundle', null, [
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
])
|
])
|
||||||
->add('documentClass', null, [
|
->add('documentClass', null, [
|
||||||
'disabled' => true,
|
'disabled' => false,
|
||||||
]) // cahcerh par default PersonDocument
|
]) // cahcerh par default PersonDocument
|
||||||
->add('name', TranslatableStringFormType::class);
|
->add('name', TranslatableStringFormType::class);
|
||||||
}
|
}
|
||||||
|
@ -61,15 +61,4 @@ class DocumentCategoryRepository implements ObjectRepository
|
|||||||
{
|
{
|
||||||
return DocumentCategory::class;
|
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