I need to create a deleteForm in my view so I do this:
/**
* 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());
}
But I get this error:
FatalErrorException: Error: Call to undefined method BankBundle\Controller\WController::createDeleteForm() in /var/www/html/src/BankBundle/Controller/WController.php line 66
What is wrong in this method? I need to use something to create the form?
Solution
I found the solution since createDeleteForm()
isn't Symfony2 method and was my mistake taking it from another code I have so I create the function in this way:
private function createDeleteForm($account_id) {
return $this->createFormBuilder(array('account_id' => $id))->add('account_id', 'hidden')->getForm();
}
And voila problem dissapear!!