简体   繁体   中英

Knp Paginator bundle and filtering option issue

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

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 !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM