symfony - pagerfanta used in a form with a search. symfony2 -


I want to present the paging link with a pager. It is worth considering the data entered in this search form.

A simple pagination link will not allow me to navigate in my search results. Any help please?

Controller

  / ** * @ ("/ {page} /", name = "admin_user", requirements = {"page" = "\ D + "}, Default = {" page "= 1}) * @ template () * / public function index action ($ page = 1) {$ data = []; $ Data ['name'] = $ this- & gt; GetUser () - & gt; GetName (); $ Form = $ this- & gt; CreateForm ('admin_user_search_type', tap); $ Request = $ this- & gt; GetRequest (); If ($ request-> getMethod () == 'POST') {$ form-> Tie ($ request); $ Data = array_merge ($ data, $ form-> getData ()); } $$ --- ($ AABundle: user: index.html.twig), array ('pager' => $ this-> getDoctrine () - & gt; getManager () - & gt; Mill Reptori (' AABundle Return: User ') - & gt; Search ($ data, 4, $ page, $ this-> getUser ()), 'form' = & gt; $ Form- & gt; CreateView (),)); } {/ Code>  

view.html.twig

  {% if pager.haveToPaginate%} {{PageRenta (pager, 'twitter_bootstrap3')}} {% endif %}  

Get methode instead of post as a solution Are capable. Apart from this, we do not have to check whether valid or not, while this is a search form.

The administrator will appear as follows:

  ** * @Route ("/ {page} /", name = "admin_user", requirements = {"page" = " \ D + "}, default = {" page "= 1}) * @ template () * / public function index action ($ page = 1) {$ data = []; $ Data ['name'] = $ this- & gt; GetUser () - & gt; GetName (); $ Form = $ this- & gt; CreateForm ('admin_user_search_type', tap); $ Request = $ this- & gt; GetRequest (); $ Form & gt; Tie ($ request); $ Data = array_merge ($ data, $ form-> getData ()); Return $ this- & gt; Get-access () - & gt; getRepoitory ('AABundle: user' ) - & gt; Search ($ data, 4, $ page, $ this- & gt; getUser ()), 'form' = & gt; $ form-> createView (),)); }  

form.html.twig

  & lt; Form name = "search" verb = "{{path ('admin_user')}}" nerve method = "get" {{form_enctype (form)}} & gt; & Lt; / Form & gt;  

Comments