dsykx64220
2012-06-20 08:12
浏览 78
已采纳

如何在Symfony 2中创建自定义表单

I have three entities : Service, Group, Agent.

Service => oneToMany => Group => oneToMany => Agent

Each of these entities already have a form. By the way, I would like to create a custom mergeForm which will contains a select field Service to choose and a select field Groupe in order to merge some of these entities. The Symfony 2 official cookbook is under maintenance, so I would like to know the way to create the custom Form in which I will be able to choose a Service (from all existing services) and to choose a Group (from all existing groups)

图片转代码服务由CSDN问答提供 功能建议

我有三个实体:服务,组,代理。

服务 => oneToMany => 群组 => oneToMany => 代理

这些实体中的每一个都有一个表单。 顺便说一句,我想创建一个自定义mergeForm,它将包含一个选择字段服务来选择,并选择一个选择字段 Groupe ,以便合并其中一些实体。 Symfony 2官方手册正在维护中,所以我想知道如何创建自定义表单,我可以在其中选择一个服务(来自所有现有服务)并选择一个组(来自所有现有组)< / p>

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongluo9156 2012-07-05 14:52
    已采纳

    What you're looking for is probably entity field type. This will allow you to embed within the form a select field that points to the foreign entity. This is primarily useful for small collections.

    When you start dealing with large collections, and find the need/desire to load entities with Javascript (e.g. The collection is to large to justify loading all on page-load), you'll have to look at Symfony2 Documentation: How to Embed a Collection of Forms.

    It's also worth noting that there is a pull request slated for Symfony 2.2 that is supposed to make dealing with this type of form easier.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题