2013-08-07 5 views
1

저는 오늘 아침 엔티티 업데이트로 인해 막혔습니다. 제가 누락 된 부분을 모르겠다. 이것은 초보자 실수라고 확신합니다.양식에서 symfony 교리 업데이트

저는 양식을 통해 무언가를 업데이트하려고합니다.

컨트롤러 :

public function editAction($pid, $plid, Request $request) 
{ 
    $plan = new Plan(); 
    $form = $this->createForm(new PlanType(), $plan); 

    $plan = $this->getDoctrine()->getRepository('QArthFrameworkBundle:Plan')->findOneByPlid($plid); 
    $project = $this->getDoctrine()->getRepository('QArthFrameworkBundle:Project')->findOneByPid($pid); 

    $form->handleRequest($request); 
    if ($request->getMethod() == 'POST') { 

      $em = $this->getDoctrine()->getManager(); 
      $em->flush(); 

      return $this->redirect($this->generateUrl('qarth_framework_plan_edit', array('pid' => $pid, 'plid' => $plid))); 
    } 

    return $this->render('QArthFrameworkBundle:Pages:plan_edit.html.twig', array(
     'plan' => $plan, 
     'project' => $project, 
     'form' => $form->createView(), 
    )); 
} 

형태 :

public function buildForm(FormBuilderInterface $builder, array $options) 
{ 
    $builder->add('name'); 
    $builder->add('description', 'textarea'); 
} 

엔터티 : 나는 내 게시물 매개 변수를 잘 게시되어 있음을 볼 수있는 프로파일 러와 http://pastebin.com/bTqKehyQ

plan {"name":"fsggsfgsf","description":"gsfgsfgsf","_token":"7d089aca0203c60fe1e617488e532ac966101440"} 

그러나 업데이트 쿼리 또는 다른 어떤 흔적도 볼 수 없습니다. 아이디어가 있다면 큰 도움이 될 것입니다.

많은 감사,

+1

당신은'지속()'호출 누락 :'$ 보하기> 지속 ($ 계획)'플러시 – cheesemacfly

+0

전에 나는 계속() 호출과 같은 동작을합니다. – benarth

답변

0

폼에 쿼리 계획을 통과해야합니다.

public function editAction($pid, $plid, Request $request) 
{ 
    $plan = $this->getDoctrine()->getRepository('QArthFrameworkBundle:Plan')->findOneByPlid($plid); 
    $project = $this->getDoctrine()->getRepository('QArthFrameworkBundle:Project')->findOneByPid($pid); 

// Create a new one if not found 
if (!$plan) $plan = new Plan(); 

// Build your form using queried or new plan 
$form = $this->createForm(new PlanType(), $plan); 

$form->handleRequest($request); 

// Checks for POST as well as validity 
if ($form->isValid()) { 

     $em = $this->getDoctrine()->getManager(); 
     $em->persist($plan); // To handle new plans, no impact for existting plans 
     $em->flush(); 

// Rest is the same