0
我嘗試做編輯表單中的Symfony如何創建編輯/更新形式
public function editAction()
{
$id = 5;
$em = $this->getDoctrine()->getEntityManager();
$request = $this->get('request');
$entity = $em->getRepository('SurgeryPatientBundle:Patients')->find($id);
$form = $this->createForm(new \Surgery\PatientBundle\Form\PatientsType(), $entity);
$form->bindRequest($request);
return $this->render('SurgeryPatientBundle:Patient:newpatient.html.twig',array('form'=>$form->createView()));
if($form->isValid())
{
//do someting
}
else
{
//do something
}
}
我仍然得到空的形式沒有數據,變量$entity
是isset。我沒有插入表單,但我無法處理編輯操作。我不想使用終端和php app/console
創建表單,因爲我想知道它是如何做到的。
返回在$ form-> isValid()之前做了什麼? – j0k
閱讀http://symfony.com/doc/current/book/forms.html –