Answer the question
In order to leave comments, you need to log in
Deal with data insertion in Doctrine?
Here is the part of the config where the links are described:
Dog:
oneToMany:
dogs:
targetEntity: Dog
mappedBy: post
cascade:
- persist
Post:
manyToOne:
post:
targetEntity: Post
inversedBy: dogs
joinColumns:
post_id:
referencedColumnName: id
$post = new Entity\Post();<br>
$form = $this->createForm(new Form\PostType(), $post);<br>
if( $request->isMethod('POST') && $form->bind($request)->isValid() ) {<br>
$post = $form->getData()->setAddDate();<br>
$em = $this->getDoctrine()->getManager();<br>
$em->persist($post);<br>
$em->flush();<br><br>
// return $this->redirect($this->generateUrl('show', array('id' => $post->getId())));<br>
}<br>
Answer the question
In order to leave comments, you need to log in
OK.
Let's go from the start.
put the description of the entity, the form and the controller with the method in the gist.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question