Symfony2; Do not use an alias in the URL using KnpPaginatorBundle

I am using a KnpPaginatorBundle and I would like to know if it is possible to get a url without an alias ( t .country) like this

/travels?sort=country&direction=asc 

I do not like

/travels?sort=t.country&direction=asc

This is the form:

<select class="select_styled white_select" id="sort_list" name="option">
            <option value="">-------</option>
    {{ knp_pagination_sortable(pagination, 'Country A-Z', 't.country', {'sort': 'country', 'direction': 'asc'}) }}
    {{ knp_pagination_sortable(pagination, 'Country Z-A', 't.country', {'sort': 'country', 'direction': 'desc'}) }}

</select>

and this is the controller:

    public function listAction($page, Request $request)
{
    $em = $this->getDoctrine()->getManager();

    $paginator  = $this->get('knp_paginator');

    $qb = $em->getRepository('ProjectTravelBundle:Travel')->getListTravelsFrontend();

    $pagination = $paginator->paginate(
        $qb,
        $request->query->get('page', $page)/*page number*/,
        10/*limit per page*/
    );

    return $this->render('ProjectFrontendBundle:Frontend:list.html.twig',array(
        'pagination' => $pagination
    ));
}

there is no decision?

+4
source share
1 answer

For what I read right now in the KnpPaginatorBundle , it seems that you need this code:

<select class="select_styled white_select" id="sort_list" name="option">
    <option value="">-------</option>
    {{ knp_pagination_sortable(pagination, 'Country A-Z', 't.country', {'direction': 'asc'}) }}
    {{ knp_pagination_sortable(pagination, 'Country Z-A', 't.country', {'direction': 'desc'}) }}

</select>
0
source

All Articles