简体   繁体   English

如何在Symfony2中创建一个切换表单?

[英]How to create a switch form in Symfony2?

For my project in symfony I need to create a certain form. 对于我在symfony中的项目,我需要创建某种形式。 The Entities and Controllers were not an issue but now that it comes to the form and view file I am stuck as to how to approach this. 实体和控制器不是问题,但是现在涉及到表单和视图文件,我对于如何解决这个问题感到困惑。 I am using twig and would like to use the Symfony forms. 我正在使用树枝,并且想使用Symfony表单。

   | Option A | Option B | Option C |
-------+----------+----------+----------+
Type A |     x    |     x    |     x    |
-------+----------+----------+----------+
Type B |     x    |     x    |     x    |
-------+----------+----------+----------+
Type C |     x    |     x    |     x    |
-------+----------+----------+----------+

The x represents a checkbox. x代表一个复选框。 Using this form the user can select a different amount of options for each Type. 使用此表格,用户可以为每种类型选择不同数量的选项。 The types are stored in an entity as are the options. 类型和选项一样存储在实体中。

How would i do something like this the Symfony way? 我将如何以Symfony的方式进行此类操作?

Edit 编辑

What I want to to is to get the results from the Type entity and the results from my Option entity. 我要从Type实体和Option实体获取结果。 The Type entity will supply the rows for a table and the Option entity will supply the columns. Type实体将提供表的行,而Option实体将提供列。 Each row will have a checkbox under every column. 每行在每一列下都有一个复选框。 This is so that I can select multiple options for each type. 这样我就可以为每种类型选择多个选项。

I need to build a form from both these entities and I can't figure out how to approach this issue. 我需要从这两个实体中构建一个表单,但我不知道如何解决此问题。

Check this bundle . 检查此捆绑包 I never use it but has a pretty good reputation. 我从不使用它,但声誉很好。

Hope this help you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM