【问题标题】:Unknown record property / related component "primary_keys" form embed/m:n relationship未知记录属性/相关组件“primary_keys”表单嵌入/m:n 关系
【发布时间】:2011-03-23 20:39:14
【问题描述】:

我有这个架构:

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 }

当我像这样嵌入 JosCoreAclAroForm 时

class JosUsersForm extends BaseJosUsersForm{
    public function configure(){


        $josCoreAclAroForm = new JosCoreAclAroForm();
                $this->embedForm('josCoreAclAro', $josCoreAclAroForm);

    }



}

我在“JosCoreAclAroGroups”上得到未知记录属性/相关组件“primary_keys”

我不知道为什么会调用这个函数,也找不到任何地方?

【问题讨论】:

  • 这似乎是对对象主键的教义检查。这是在教义框架中。你检查你的日志了吗?不知道 symfony 中的“embedForm”方法,你用的是 1.4 版还是尝试 2 版?
  • getPrimaryKeys 在 DoctrineCollection 中,但是模型 Class JosCoreAclAroGroups 不是 DoctrineCollection 的后代
  • 我发现创建函数 getPrimaryKeys(){ return array('group_id','aro_id');} 可以解决问题,但我不确定它是否会正确保存。网上评论说 RefClass 有复合主键可能有问题?
  • 我刚试了单字段主键,同样的错误信息
  • 类名应该是单数,并且由于学说会根据名称是否以 s 结尾做出许多猜测,这可能是您的问题的根源,JosCoreAclAroGroups 末尾的 s 可能会被误解某处。

标签: symfony1 doctrine many-to-many


【解决方案1】:

Greg0ire 的答案是:“类名应该是单数的,并且由于学说会根据名称是否以 s 结尾做出许多猜测,这可能是您的问题的根源,JosCoreAclAroGroups 末尾的 s 可能是在某处被误解了。”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-29
    • 2023-04-01
    • 1970-01-01
    • 2011-08-24
    相关资源
    最近更新 更多