Bonjour,
Quand je clicque le bouton suivant pour knppaginator (« Previous | 1 | 2| Next »),, il ne fonctionne pas.
Aide-moi svp!!!
XXXXcontroller.php
/**
* @Route("/etudiants", name="developa_admin_etudiant_admin")
*/
public function index(Request $req, PaginatorInterface $paginator): Response
{
$em = $this->getDoctrine()->getManager();
$tab = $req->request->get('del');
if (!is_null($tab) && !empty($tab)) {
foreach ($tab as $id) {
$entity = $em->getRepository(Etudiant::class)->find($id);
if (!is_null($entity))
$em->remove($entity);
}
$em->flush();
$this->addFlash('success','L\'étudiant(e) a bien été supprimé(e).');
}
$query = $em->getRepository(Etudiant::class)->getAll('ETUDIANT');
// $paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$query,
$req->query->getInt('p', 1),
6
);
return $this->render('admin/etudiants.html.twig', [
'controller_name' => 'EtudiantsController',
'tab' => $pagination,
]);
}
Mon xxx.html.twig:
<div class="navigation mt-4">
{{ knp_pagination_render(tab) }}
</div>
bundles.php
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],