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>