public function newAction($project) { $em = $this->container->get('doctrine.orm.entity_manager'); $task = new Task(); $task->setOwner($this->container->get('security.context')->getUser()); // preload form with you as owner $task->setProject($project); // set the project for when the form gets submitted $task->setDueDate(new \DateTime()); // set the project for when the form gets submitted $form = new TaskForm('task', $task, $this->container->get('validator'), array('entity_manager' => $em)); return $this->render('ChiaBundle:Tasks:form.twig', array('form' => $form)); }
/** * Add task * * @param Application\ChiaBundle\Entity\Task $task */ public function addTask(\Application\ChiaBundle\Entity\Task $task) { $task->setProject($this); $this->tasks[] = $task; }