我正在尝试使用sfWidgetFormDoctrineChoiceMany
Symfony小部件将数据插入数据库表。由于某些未知原因,如果从每个字段中选择2个值,则将插入数据,但如果在一个字段中选择3并且在另一个字段中仅选择1或2,则不会插入数据,如下所示:
但是当我尝试这样做时出现错误:
我正在使用Doctrine在数据库中生成我的表。这是我的架构:
#Article tables
SteerCmsArticle:
columns:
title: string(255)
content: string
file: string(255)
date_created: string(255)
active: boolean
relations:
Tags:
class: SteerCmsArticleTags
local: a_id
foreign: a_tag_id
refClass: SteerCmsTaggedArticles
Categories:
class: SteerCmsArticleCat
local: a_id
foreign: a_cat_id
refClass: SteerCmsCategorisedArticles
SteerCmsArticleCat:
columns:
name: string(255)
SteerCmsArticleTags:
columns:
name: string(255)
SteerCmsTaggedArticles:
columns:
a_id: integer(20)
a_tag_id: integer(20)
relations:
SteerCmsArticle:
onDelete: CASCADE
local: a_id
foreign: id
SteerCmsArticleTags:
onDelete: CASCADE
local: a_tag_id
foreign: id
SteerCmsCategorisedArticles:
columns:
a_id: integer(20)
a_cat_id: integer(20)
relations:
SteerCmsArticle:
onDelete: CASCADE
local: a_id
foreign: id
SteerCmsArticleCat:
onDelete: CASCADE
local: a_cat_id
foreign: id
答案 0 :(得分:0)
我无法相信,在生成表单和验证器时,我实际上是多么愚蠢地从头开始重建我的模型一个简单的拼写错误。确保您的验证器与表格三重检查拼写正确对应!
'categories_list' => new sfValidatorDoctrineChoiceMany(array('model' => 'SteerCmsArticle**Tags**', 'required' => false)),
真的是......
'categories_list' => new sfValidatorDoctrineChoiceMany(array('model' => 'SteerCmsArticle**Cats**, 'required' => false)),