Search code examples
phpsymfonypagerfanta

Symfony2 Pager Fanta


Is it posible to set the route / render controller with pager fanta in symfony2 because i have tried rendering a controller and it hits me with cannot generate route:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "" as such route does not exist.") in @AppBundle\Survey\table_questions.html.twig at line 27.

On line 27 i have

{{ pagerfanta(pager, 'twitter_bootstrap3') }}

Solution

  • I don't know how exactly you use the WhiteOctoberPagerfantaBundle but you can set your default view: https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle#adding-views. Also see this answer: Customising the layout of Pagerfanta pagination with a custom template.

    Alternatively, the pagerfanta function takes a third argument with options to create the route generator. https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle/blob/master/Twig/PagerfantaExtension.php#L100.

    Notably routeName might be enough for what you need to do:

    {{ pagerfanta(pager, 'twitter_bootstrap3', {routeName: 'route_name'}) }}