symfony - embeddedForm - 多个复选框

问题描述 投票:0回答:1

我有文章管理模块和标签模块标签只是每个行项目的单个标签

我想要做的是将所有标签的列表(作为复选框)嵌入到我的文章模块中

我可以用嵌入式表格做到这一点吗?

编辑:

这是我的架构:

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 }

所以当我需要显示标签时,会更新上面的表格

symfony1 symfony-1.4 symfony-forms
1个回答
0
投票

如果已在模型中正确定义了文章和标记之间的关系,则生成的表单应包含标记选择小部件。

在Forms文档中搜索“sfWidgetFormChoice”以获取更多信息:http://www.symfony-project.org/jobeet/1_4/Doctrine/en/10

注意:这些示例是使用Doctrine ORM创建的,但是一切都应该与Propel一样。

© www.soinside.com 2019 - 2024. All rights reserved.