Symfony1 未知记录属性/相关组件“;主“U键”;表单嵌入/m:n关系
我有这个模式:Symfony1 未知记录属性/相关组件“;主“U键”;表单嵌入/m:n关系,symfony1,doctrine,many-to-many,Symfony1,Doctrine,Many To Many,我有这个模式: JosUsers: columns: id: { type: integer(4), primary: true, autoincrement: true } name: { type: string(255), notnull: true } username: { type: string(150), notnull: true } email: { type: string(100), notnull: true } passwo
JosUsers:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
name: { type: string(255), notnull: true }
username: { type: string(150), notnull: true }
email: { type: string(100), notnull: true }
password: { type: string(100), notnull: true }
usertype: { type: string(25), notnull: true }
block: { type: integer(1), notnull: true }
sendemail: { type: integer(1), notnull: false }
gid: { type: integer(1), default: '1', notnull: true }
registerdate: { type: timestamp(25), notnull: true }
lastvisitdate: { type: timestamp(25), notnull: true }
activation: { type: string(100), notnull: true }
params: { type: string(), notnull: true }
relations:
AccessControlObject: { class: JosCoreAclAro, local: id, foreign: value, foreignType: one }
JosCoreAclAro:
columns:
id: { type: integer(4),fixed: false, unsigned: false, primary: true, autoincrement: true}
section_value: { type: string(240), notnull: true }
value: {type: string(240), notnull: true }
order_value: { type: integer(4), notnull: true }
name: { type: string(255), notnull: true }
hidden: { type: integer(4), notnull: true }
relations:
Group: { class: JosCoreAclAroGroups, local: aro_id, foreign: group_id, refClass: JosCoreAclGroupsAroMap,foreignType: one }
JosCoreAclGroupsAroMap:
columns:
group_id: { type: integer(4), primary: true }
section_value: { type: string(240) }
aro_id: { type: integer(4), primary: true }
relations:
JosCoreAclAro: { class: JosCoreAclAro, local: aro_id, onDelete: CASCADE }
JosCoreAclAroGroup: { class: JosCoreAclAroGroups, local: group_id, onDelete: CASCADE }
JosCoreAclAroGroups:
columns:
id: {type: integer(4), primary: true, autoincrement: true }
parent_id: { type: integer(4), notnull: true }
name: { type: string(255), notnull: true }
lft: { type: integer(4), notnull: true }
rgt: { type: integer(4), notnull: true }
value: { type: string(255), notnull: true }
当我像这样嵌入JosCoreAcroForm时
class JosUsersForm extends BaseJosUsersForm{
public function configure(){
$josCoreAclAroForm = new JosCoreAclAroForm();
$this->embedForm('josCoreAclAro', $josCoreAclAroForm);
}
}
我在“JosCoreAcroGroups”上获得未知记录属性/相关组件“primary_keys”
我不明白为什么会调用这个函数,也找不到它的任何地方?GregFire给出了答案:“类名应该是单数的,因为条令根据名称是否以s结尾进行了很多猜测,这可能是问题的根源,JosCoreAcroGroups结尾的s可能在某个地方被误解。”这似乎是在检查对象的主键。这是在理论框架内。你查过日志了吗?我不知道symfony中的“EmbeddeForm”方法,您是使用1.4版还是尝试2版?getPrimaryKeys在DoctrineCollection中,但是模型类JosCoreAcroGroups不是DoctrineCollection的后代我发现创建函数getPrimaryKeys(){return array('group_id','aro_id');}解决了问题,但我不确定它是否能正确保存。网上评论说RefClass使用复合主键可能有问题?我刚刚尝试了一个单字段主键,相同的错误消息类名应该是单数,而且由于条令根据名称是否以s结尾进行了许多猜测,这可能是问题的根源,组末尾的s可能在某些地方被误解。