变量 'filterForm' 不存在

variable 'filterForm' does not exist

我想使用包 "PetkoparaMultiSearchBundle" 做一个搜索表单,但是当我尝试使用

将表单放在我的树枝上时出现此错误
 {{ form_rest(filterForm) }}

这是我的 searchtype.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'));
}

}

我做错了什么?

您必须将表单传递给视图。将此添加到您的控制器。

 return $this->render(
     'Bundle:Controller:view.html.twig',
      array(
          'filterForm' => $filterForm->createView()
      )
 );