Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 persist correlated objects
    primarykey
    data
    text
    <p>This my issue: <strong>Entity AddressBook</strong> <em>1-N</em> <strong>Entity Number</strong></p> <p>The controller displays the edit form with AddressBook and its number, but when I save the form, I get this error: <strong>Fatal error: Call to a member function setTipo() on a non-object</strong> </p> <p>Strangely, however, the data is saved correctly</p> <p>This my code:</p> <pre><code> /** * Modifica dati Anagrafica * @Route("/contatto/{id}/modifica", name="_anagrafica_modifica") * @Template() */ public function modificaAction($id) { $em = $this-&gt;getDoctrine()-&gt;getManager(); $anagrafica = $em-&gt;getRepository('MercurioInterfaceBundle:Anagrafica')-&gt;find($id); if (!$anagrafica) { throw $this-&gt;createNotFoundException('No anagrafica found for id '.$id); } $form = $this-&gt;createForm(new \Mercurio\InterfaceBundle\Form\Anagrafica\FormAnagrafica(), $anagrafica); $request = $this-&gt;getRequest(); if ($request-&gt;getMethod() == 'POST') { $form-&gt;bind($request); if ($form-&gt;isValid()) { $chiave = $request-&gt;request-&gt;get('anagrafica'); $em = $this-&gt;getDoctrine()-&gt;getManager(); $anagrafica = $em-&gt;getRepository('MercurioInterfaceBundle:Anagrafica')-&gt;find($id); $anagrafica-&gt;setNominativo($chiave['nominativo']); $anagrafica-&gt;setIndirizzo($chiave['indirizzo']); $anagrafica-&gt;setCap($chiave['cap']); $anagrafica-&gt;setCitta($chiave['citta']); $anagrafica-&gt;setNote($chiave['note']); $em-&gt;flush(); $dettaglio = $em-&gt;getRepository('MercurioInterfaceBundle:AnagDettaglio')-&gt;findBy(array('anagrafica_id' =&gt; $id,)); foreach ($chiave['anag_dettagli'] as $d) { $dettaglio-&gt;setTipo($d['tipo']); $dettaglio-&gt;setValore($d['valore']); $dettaglio-&gt;setRiferimento($d['riferimento']); } $em-&gt;flush(); return $this-&gt;redirect($this-&gt;generateUrl('_anagrafica_contatto', array('id' =&gt; $id))); } } return array( 'form' =&gt; $form-&gt;createView(), 'id' =&gt; $id ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload