symfony - Call an entity method in a controller -


i have 3 entities: invoice,payment , result

the relationships between entities are: result(1,1)-------------(1,n)invoice(1,n)---------------(1,1)payment here's problem :i in paymentcontroller when create new payement ,i retrieve invoice entity , in same paymentcontroller create new result.

here's paymentcontroller code:

use myapp\accountbundle\entity\result; class paymentcontroller  extends controller   public function createaction()     {      $entity  = new payment();      $request = $this->getrequest();      $form    = $this->createform(new paymenttype(), $entity);      $form->bindrequest($request);      $amount=$form->get('amountreceived')->getdata();     if ($form->isvalid()) {         $em = $this->getdoctrine()->getentitymanager();         $invoice = em->getrepository('myappaccountbundle:invoice')->find($entity->getinvoice()->getid())         if (!$invoice) {         throw $this->createnotfoundexception('unable find invoice entity.');             }               $result=new result();              $result=setdebitamount($amount);      $result=setcreditamount(0);      $result=setinvoice($invoice);              $em->persist($result);              $em->persist($entity);              $em->flush();        return $this->redirect($this->generateurl('payment_show', array('id' =>   $entity->getid())));        }     return $this->render('myappaccountbundle:payment:new.html.twig', array(         'entity' => $entity,         'form'   => $form->createview()     )); 

when execute paymentcontroller (in view) error: fatal error: call undefined function myapp\accountbundle\controller\setdebitamount() in c:\wamp\www\account\src\ myapp\accountbundle\controller\paymentcontroller.php on line...

thank in advance

change = ->

$result=setdebitamount($amount); 

must be

$result->setdebitamount($amount); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -