symfony - embeddedForm - multiple checkboxes

半城伤御伤魂 提交于 2019-12-11 17:52:29

问题


I have article admin module and a tag module Tags are simply a single tag per row item

What I'd like to do is to embed the list of all the tags (as checkboxes) into my article module

Could I do this with embedded forms?

EDIT:

This is my schema:

article:
  id:                                      ~
  title:                                   { type: VARCHAR, size: '255', required: true }
  tags:                                    { type: VARCHAR, size: '500' }
  created_at:                              { type: TIMESTAMP, required: true }
  updated_at:                              { type: TIMESTAMP, required: true }

tag:
  id:                                      ~
  tag:                                     { type: VARCHAR, size: '500', required: true } 
  ord_id:                                  { type: INTEGER,  required: true }
  created_at:                              ~
  updated_at:                              ~

item_tag:
  id:                                      ~
  item_id:                                 { type: INTEGER, required: true, foreignTable: item, foreignReference: id, onDelete: cascade }
  tag_id:                                  { type: INTEGER, required: true, foreignTable: tag, foreignReference: id, onDelete: restrict }
  created_at:                              ~

item:
  id:                                      ~
  article_id:                              { type: INTEGER, foreignTable: article, foreignReference: id, onDelete: cascade }

So when I need the tags to be displayed and will update the above tables


回答1:


If you have defined the relationship between the article and tags correctly in your model, then the generated Forms should contain tag select widgets.

Search "sfWidgetFormChoice" in the Forms documentation for more information: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/10

Note: The examples are created using the Doctrine ORM but everything should work the same way with Propel as well.



来源:https://stackoverflow.com/questions/4805591/symfony-embeddedform-multiple-checkboxes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!