我希望 pagerfanta 呈现的分页链接与表单数据一起提交。这是考虑在搜索表单中输入的数据。
一个简单的分页链接将不允许我在搜索结果中导航。请问有什么帮助吗?
控制器
/**
* @Route("/{page}/", name="admin_user",requirements={"page" = "\d+"}, defaults={"page" = 1})
* @Template()
*/
public function indexAction($page = 1)
{
$data = [];
$data['name'] = $this->getUser()->getName();
$form = $this->createForm('admin_user_search_type', null);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bind($request);
$data = array_merge($data, $form->getData());
}
return $this->render('AABundle:User:index.html.twig', array(
'pager' => $this->getDoctrine()->getManager()->getRepoitory('AABundle:User')->search($data, 4, $page, $this->getUser()),
'form' => $form->createView(),
));
}
view.html.twig
{% if pager.haveToPaginate %}
{{ pagerfanta(pager, 'twitter_bootstrap3') }}
{% endif %}