在symfony2中调用数组上的成员函数setTopic()

时间:2016-02-03 09:16:09

标签: php symfony

public function updateSubTopicAction(Request $request ,$id) {
     $updatesubtopic = $this->getDoctrine()
             ->getRepository('FeedbackBundle:Subtopics')
             ->findASubtopics($id);
     //print_r($updatesubtopic);die;

     if ($request->getMethod() == 'POST') {
         $update = $request->request->all();
         //print_r($update);die;
         $updatesubtopic->setTopic($update['Topicname']);
         $updatesubtopic->setName($update['subtopicname']);
         $updatesubtopic->setDetails($update['subtopicdetails']);
         //print_r($updatesubtopic);die;
         $em = $this->getDoctrine()->getManager();
         $em->persist($updatesubtopic);
         $em->flush();
         return new RedirectResponse($this-generateUrl('view_topic'));
     }
     return $this-render(
         'FeedbackBundle:SubTopic:update_sub_topic.html.php',
         array('updatesubtopic'=>$updatesubtopic)
     );
}

如何更新数据?

0 个答案:

没有答案