2016-06-27 21 views
0

我有一個錯誤,無法找到它從缺少的論點2:Symfony3爲CommonBundle 控制器 {}關閉()

->add('Webmaster',   ChoiceType::class, array(
     'required' => false, 
     'choices' => $listWebmasters, 
     'choice_label' => function($value, $key, $index) 
     { 
      return ($this->getDoctrine()->getManager()->getRepository('CommonBundle:Compte')->find($value)->getNom().' '.$this->getDoctrine()->getManager()->getRepository('CommonBundle:Compte')->find($value)->getPrenom()); 
     }, 
     'choice_value' => function($value, $key, $index)//Line of the error 
     { 
      return ($this->getDoctrine()->getManager()->getRepository('CommonBundle:Compte')->find($value)->getNom().' '.$this->getDoctrine()->getManager()->getRepository('CommonBundle:Compte')->find($value)->getPrenom()); 

     })) 

我想沒有「choice_value」選項,它的工作原理;我嘗試了一個'choice_label'的副本,但仍然無法正常工作。 'choice_value'被用作'choice_label'。 http://symfony.com/doc/current/reference/forms/types/choice.html#choice-value

編輯

確切的錯誤:

Warning: Missing argument 2 for CommonBundle\Controller\DefaultController::CommonBundle\Controller{closure}()

+0

你可以編輯你的文章,並顯示確切的錯誤是什麼? –

+0

完成。這與標題完全相同。 –

+0

錯誤消息似乎指向您的控制器代碼。你能在其他地方發佈更多嗎? –

回答

1

嘗試刪除從參數$鍵和$指數。它幫助了我。

'choice_value' => function($value) 
    { 
     ... 
    } 
+0

這對你有什麼幫助? – Acapulco

+0

它工作,如果你正在處理一個EntityType ::類 – Charly