I am trying to edit a form i get the form with existing values correctly but when i try to put new data in fields and submit the form i get an error of Call to a member function setName() on a non-object
My controller method is
public function editAction(Request $request){
$request = Request::createFromGlobals();
$group_id = $request->query->get('id');
$em = $this->getDoctrine()->getEntityManager();
$patent_group = $em->getRepository('MunichInnovationGroupBundle:PmPatentgroups')->find($group_id);
//echo '<pre>';
//print_r($patent_group);
//echo '</pre>';
$form = $this->createForm(new PatentgroupType(), $patent_group);
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
$name = $form["name"]->getData();
$description = $form["description"]->getData();
$patent_group->setName($name);
$patent_group->setDescription($description);
$em->flush();
return $this->redirect($this->generateUrl('MunichInnovationGroupBundle_portfolio'));
}
return $this->render('MunichInnovationGroupBundle:Patentgroups:edit.html.twig', array(
'form' => $form->createView(),
'group_id' => $group_id
));
}
This is what I get in $patent_group
MunichInnovationGroup\Bundle\Entity\PmPatentgroups Object
(
[id:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => c3e0eb98-ada5-11e1-96a5-9787dec335c2
[name:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => Zoha Ali khan
[description:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => No Description Provided for this Group
[portfolio_id:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => Proxies\MunichInnovationGroupBundleEntityPmPortfoliosProxy Object
(
[_entityPersister:Proxies\MunichInnovationGroupBundleEntityPmPortfoliosProxy:private] => Doctrine\ORM\Persisters\BasicEntityPersister Object
(
[_class:protected] => Doctrine\ORM\Mapping\ClassMetadata Object
(
[reflFields] => Array
(
[id] => ReflectionProperty Object
(
[name] => id
[class] => MunichInnovationGroup\Bundle\Entity\PmPortfolios
)
[portfolioName] => ReflectionProperty Object
(
[name] => portfolioName
[class] => MunichInnovationGroup\Bundle\Entity\PmPortfolios
)
What i am doing wrong here as i am getting this error
Call to a member function setName() on a non-object
Any Ideas? Thanks in advance