我需要在我看來,以創建一個deleteForm所以我這樣做:調用未定義的方法不能創建createDeleteForm
/**
* Show created bank account
*
* @Route("/{account_id}", name="wba_show")
* @Method("GET")
*/
public function showAction($account_id) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('BankBundle:Account')->find($account_id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Account entity.');
}
$deleteForm = $this->createDeleteForm($account_id);
return array('entity' => $entity, 'delete_form' => $deleteForm->createView());
}
但我得到這個錯誤:
FatalErrorException: Error: Call to undefined method BankBundle\Controller\WController::createDeleteForm() in /var/www/html/src/BankBundle/Controller/WController.php line 66
什麼是錯的這種方法?我需要使用一些東西來創建表單?
解決方案 我找到了解決方案,因爲createDeleteForm()
不Symfony2的方法是我的錯誤,從另一個代碼我服用它,所以我用這種方式創建函數:
private function createDeleteForm($account_id) {
return $this->createFormBuilder(array('account_id' => $id))->add('account_id', 'hidden')->getForm();
}
瞧問題dissapear !
謝謝,我會試試 – Reynier