0
我想用一包「PetkoparaMultiSearchBundle」做搜索的形式,但我得到這個錯誤,當我嘗試使用變量「filterForm」不存在
{{ form_rest(filterForm) }}
這裏是我的檢索類別把表單上我的樹枝。 PHP
class SearchType extends AbstractType{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('search', MultiSearchType::class, array(
'class' => 'SpoiledCarFrontOfficeBundle:Voiture'));
}
}
,這裏是我的控制器
* Search a Voiture .
*
* @Route("/profile/shop", name="fos_user_profile_listTable")
* @Method({"GET", "POST"})
*/
public function listTableAction(Request $request)
{
$search = $request->get('search');
$em = $this->getDoctrine()->getManager();
$queryBuilder = $em->getRepository('SpoiledCarFrontOfficeBundle:Voiture')- >createQueryBuilder('e');
$filterForm = $this->createForm('SpoiledCarFrontOfficeBundle\Form\SearchType');
// Bind values from the request
$filterForm->handleRequest($request);
if ($filterForm->isValid()) {
// Build the query from the given form object
$queryBuilder = $this->get('petkopara_multi_search.builder')->searchForm($queryBuilder, $filterForm->get('search'));
}
}
什麼,我做錯了什麼?
您不會傳遞'$ filterForm'來查看圖層,因此它在那裏不可用。 –