我正在开发一个Web应用程序。 我有应该从网上创建和编辑的实体(相当经典,不是它)。 p>
所以我想使用表单生成(使用Type和Handler)Symfony 提供,但我不想简单地以标准方式打印它们。 我想从jquery中调用这些表单,以便我可以在jQuery插件中使用验证等,例如 jEditable strong>。 p>
因此,我认为最好的方法是将我的表单作为json发送到jquery函数,该函数将把它放在我的HTML元素中。 p>
\ n 我做了什么: p>
jQuery: strong> p>
控制器: strong> p>
json_encode()实际上不发送任何内容,因为$ form是一个对象。 现在我有几个问题: p>
提前致谢! p>
div>
$。get(“getorganisationform” /“+ curOId,function(data){
if(data.responseCode == 200){
$(”#innerModal“)。append(data.form);
}
});
< / code> pre>
$ form = $ this-&gt; createForm(new OrganisationType, $ organization);
$ formHandler = new OrganisationHandler($ form,$ this-&gt; get('request'),$ this-&gt; getDoctrine() - &gt; getEntityManager());
if ($ formHandler-&gt; process())
{
返回$ this-&gt;重定向($ this-&gt; generateUrl('adminpanel'));
}
返回新响应(json_encode($ form),200);
code> pre>