我正在尝试合并两个实体(用户和学生)来创建一个表单,下面是我的 orm 文件
Ens\JobeetBundle\Entity\User:
type: entity
table: abc_user
id:
user_id: { type: integer, generator: { strategy: AUTO } }
fields:
username: { type: string, length: 255, notnull: true, unique: true }
email: { type: string, length: 255, notnull: true, unique: true }
password: { type: string, length: 255, notnull: true }
enabled: { type: boolean }
oneToOne:
student:
targetEntity: Ens\JobeetBundle\Entity\Student
mappedBy: user
Ens\JobeetBundle\Entity\Student:
type: entity
table: abc_student
id:
student_id: { type: integer, generator: { strategy: AUTO } }
fields:
first_name: { type: string, length: 255, notnull: true }
middle_name: { type: string, length: 255 }
last_name: { type: string, length: 255, notnull: true }
oneToOne:
user:
targetEntity: Ens\JobeetBundle\Entity\User
joinColumn:
name: user_id
referencedColumnName: user_id
创建实体和更新方案工作正常,
php app/console doctrine:generate:entities EnsJobeetBundle
php app/console doctrine:database:update --force
但是当试图产生crud时
php app/console generate:doctrine:crud --entity=EnsJobeetBundle:Student
我最终遇到以下错误,
[RuntimeException]
The CRUD generator expects the entity object has a primary key field named "id" with a getId() method.
有谁知道如何摆脱这个?如何在 Symfony 2 中合并两个表单?
任何帮助都感激不尽...