Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Totally forgot that I had this question still floating around... Anyway I got around my problem, still don't know why I got the error but I solved it with quite a easy solution.</p> <p>Instead of setting the parent for the child, I did the reverse and set the child for the parent. My code is the following (There is also new code in there that's irrelevant because I fixed it some time ago).</p> <pre><code>public function popupChildAction($parentid) { $parent = $this-&gt;getDoctrine() -&gt;getRepository('MelvinLoosCMSCoreBundle:Page') -&gt;findOneById($parentid); if (!$parent) { throw $this-&gt;createNotFoundException('No parent found with given id: "' . $parentid . '"'); } $entity = new Page(); $entity-&gt;setWebsite($this-&gt;getWebsite()); $entity-&gt;setCreatedBy($this-&gt;getUser()); $form = $this-&gt;createForm(new PageChildType(), $entity); $request = $this-&gt;getRequest(); $form-&gt;bindRequest($request); if ($form-&gt;isValid()) { $em = $this-&gt;getDoctrine()-&gt;getEntityManager(); $parent-&gt;setChildren($entity); $em-&gt;persist($entity); $em-&gt;flush(); return $this-&gt;redirect($this-&gt;generateUrl('page_show', array('id' =&gt; $entity-&gt;getId()))); } return $this-&gt;render('MelvinLoosCMSCoreBundle:Page:new_popup.html.twig', array( 'entity' =&gt; $entity, 'form' =&gt; $form-&gt;createView(), 'parent' =&gt; $parent )); } </code></pre> <p>Like I said there is newer code that is irrelevant but what it's all about is the part with <code>$parent-&gt;setChildren($entity);</code> and now it works... hope this helps someone! Thanks for everyone that gave input!</p>
    singulars
    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.
    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