我发送了PUT json请求但是无法通过表单将我的javascripts模型绑定到实体,该怎么做:
public function updateAction(Request $request, $id)
{
$fb = $this->get('fire_php');
$em = $this->getDoctrine()->getManager();
$progress = $em->getRepository('CodeCatsPanelBundle:Progress')->find($id);
$form = $this->createForm(new ProgressType(), $progress);
$fb->log($request->getContent());
//from firebug:
//PUT http://pc.t/app_dev.php/panel/progress/5?_dc=1397662229471
//{"id":5,"title":"aaa","description":"lllll","started":"2014-03-18"}
$form->handleRequest($request);
$fb->log($form->isValid());
//false :(
return new JsonResponse(array('success' => true));
}
}
进行中类型:
$builder
->add('title')
->add('description')
->add('started', 'date', array(
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
));
答案 0 :(得分:0)
您应该将JSON数据反序列化为数组,并将该数组提供给表单。