ビューで deleteForm を作成する必要があるため、次のようにします。
/**
* 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: エラー: /var/www/html/src/BankBundle/Controller/WController.php 行 66 の未定義メソッド BankBundle\Controller\WController::createDeleteForm() の呼び出し
この方法の何が問題なのですか? フォームを作成するために何かを使用する必要がありますか?
Symfony2メソッドではないため、解決策
を見つけました。createDeleteForm()
私が持っている別のコードからそれを取得するのは私の間違いだったので、この方法で関数を作成します:
private function createDeleteForm($account_id) {
return $this->createFormBuilder(array('account_id' => $id))->add('account_id', 'hidden')->getForm();
}
そして出来上がりの問題は消えます!!