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 –