变量' filterForm'不存在

时间:2017-04-13 13:18:25

标签: forms symfony controller twig bundle

我想使用捆绑包进行搜索表单" 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'));
}

}

我做错了什么?

1 个答案:

答案 0 :(得分:0)

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

ALTER PROCEDURE [dbo].[SelectOpponentID]
@orderID      uniqueidentifier
AS
BEGIN
    SET NOCOUNT ON;

    SELECT opponent
    FROM tblOrders
    WHERE orderID = @orderID
END