具有两个类和关系的形式
我在 Doctrine 1.2 中有:
User:
columns:
login: { type: string(255), notnull: true }
password: { type: string(255), notnull: true }
Student:
columns:
user_id: { type: integer, notnull: true }
school_name: { type: string(255) }
school_year: { type: integer(4) }
relations:
User: { onDelete: CASCADE, local: user_id, foreign: id }
Teacher:
columns:
user_id: { type: integer, notnull: true }
city: { type: string(255) }
street: { type: string(255) }
relations:
User: { onDelete: CASCADE, local: user_id, foreign: id }
如果我打开 localhost/user/new 则有以下形式:
login:
password:
这很好。
如果我打开 localhost/student/new 的形式为:
user_id
school_name:
school_year:
但我想:
login:
password:
school_name:
school_year:
如何做到这一点?感谢您的帮助!
i have in Doctrine 1.2:
User:
columns:
login: { type: string(255), notnull: true }
password: { type: string(255), notnull: true }
Student:
columns:
user_id: { type: integer, notnull: true }
school_name: { type: string(255) }
school_year: { type: integer(4) }
relations:
User: { onDelete: CASCADE, local: user_id, foreign: id }
Teacher:
columns:
user_id: { type: integer, notnull: true }
city: { type: string(255) }
street: { type: string(255) }
relations:
User: { onDelete: CASCADE, local: user_id, foreign: id }
if i open localhost/user/new have in form:
login:
password:
this is good.
if i open localhost/student/new have in form:
user_id
school_name:
school_year:
but i would like:
login:
password:
school_name:
school_year:
how to do this? thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用名为 embedRelation 的 sfForm 方法。您必须创建一个扩展userForm的新表单并设置(在配置方法中)与Student的嵌入关系。
例如:
检查 这个例子完美地解释了如何使用它。
You have to use a sfForm method called embedRelation. You have to create a new form extending userForm and set (in the configure method) the embed relation with Student.
For example:
Check this example that explains perfectly how to use it.