Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private function renderFilteredPersonList(Request $request, QueryBuilder $queryB, $resetRoute)
{
$personForm = $this->createForm(PersonFilterType::class, null, [
'method' => 'GET'
]);
$personForm->handleRequest($request);
if ($personForm->get('reset')->isClicked()) {
$this->addFlash(
'alert-warning',
'filter.cleared'
);
return new RedirectResponse($request->getPathInfo());
}
if ($request->query->has($personForm->getName())) {
$qb_updater = $this->get('lexik_form_filter.query_builder_updater');
$qb_updater->setParts(array(
'__root__' => 'p',
'p.adressData' => 'a',
'p.adminAdressData' => 'aa',
'p.eyeColor' => 'e'
));
$qb_updater->addFilterConditions($personForm, $queryB);
if ($personForm->get('search')->isClicked()) {
$this->addFlash(
'alert-success',
'filter.applied'
);
}
}
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$queryB,
// $queryB->getQuery()->setHint(
// 'knp_paginator.count',
// $this->getParameter("paginator.limit")?:10000000
// ), // ->setMaxResults(10),
$request->query->getInt('page', 1)/*page number*/,
5/*limit per page*/,
array('defaultSortFieldName' => 'p.surname', 'defaultSortDirection' => 'asc')
);
// $res=$personForm->getNormData();
// array_map('utf8_encode', $res);
// $j = json_encode(§res);
// dump($j);
//
// parameters to template
return $this->render(
'person/person.list.html.twig',
array(
'personForm' => $personForm->createView(),
'pagination' => $pagination
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.