1
votes

im using knp Paginator bundle in a page that contains a list of records and in the same page exist a search box that can give the option to search over the list of records. after i give filter term and i hit the search button the list is dislayed well in the page, but when the list exeeds the limit number for every page and i hit for example the page 2 button of knp bundle paginator it loads me all the records , it doesn't remember the term i entered.

you will find my method action used for filtering :

public function searchAction(Request $request)
    {

        $em = $this->getDoctrine()->getManager();
        $form =  $this->createSearchForm();
        $form->handleRequest($request);
        //initialisation de l'objet paginator
        $paginator  = $this->get('knp_paginator');

            $data=$form->getData();
            $entities = $em->getRepository('EnsDataBundle:Data')->findterm($data['searchterm']);

            $pagination = $paginator->paginate($entities, $this->get('request')->query->get('page', 1),3);


            return $this->render('EnsDataBundle:Data:index.html.twig', array(
                'entities' => $pagination,
                'form' => $form->createView(),
            ));
    }

the method above works very well without knp paginator bundle,so the problem is how i can make knp paginator bundle use the same search term ($data['searchterm']) on multiple pages

1

1 Answers

4
votes

One solution is to use a GET form, not a POST form.

If you use GET, the parameters are in the url, so the parameters are on the link for next page !