我刚开始使用 symfony 1.4 和 Doctrine。(以前使用过 1.0 - 1.2 + Propel)。
我想尝试一下 Doctrine,因为过去的快速和巨大的开发过程。
感谢 jwage ;-)
我使用表继承。这是我的 schema.yml 的一小部分:
Articles:
columns:
id:
type: integer(4)
primary: true
notnull: true
autoincrement: true
marken_id:
type: integer(4)
notnull: false
user_id:
type: integer(4)
notnull: false
address_id:
type: integer(4)
notnull: false
...
Vehicles:
inheritance:
extends: Articles
type: concrete
Rennfahrzeuge:
columns:
stvo:
type: boolean
notnull: false
default: false
inheritance:
extends: Vehicles
type: concrete
Tourenwagen:
inheritance:
extends: Rennfahrzeuge
type: column_aggregation
keyField: type
keyValue: 1
...
Sonstige:
inheritance:
extends: Rennfahrzeuge
type: column_aggregation
keyField: type
keyValue: 6
Karts:
inheritance:
extends: Vehicles
type: concrete
TonyKart:
inheritance:
extends: Karts
type: column_aggregation
keyField: type
keyValue: 1
...
Sonstige:
inheritance:
extends: Karts
type: column_aggregation
keyField: type
keyValue: 9
我现在正在考虑使用一种简单的方法来创建正确的表单。
用户应该必须选择表单顶部的字段(如您可以在此处看到的:http: //msm-esv.dyndns.org/frontend_dev.php/fahrzeuge/insert )
您应该选择“父类”,例如 Rennfahrzeuge 或 Karts 等。
之后,用户应该选择像 Tourenwagen 或 Sonstige 这样的子类。
然后页面应该重新加载并显示正确的表单。
Doctrine 中是否有任何函数可以获取继承/子类以在第二个选择字段中显示它们?
(例如 Rennfahrzeuge 有 Tourenwagen,..,..., Sonstige 和 Karts 有 TonyKart,...,...,Sonstige)
之后,我可以动态创建分配的表单类,例如:
$chooseMode = $request->getParameter('chooseMode').'Form';
$modeFormClass = new $chooseMode();
或者我考虑过在父表单类中设置正确的模型。
你怎么认为?我真的很感激任何建议和帮助:-)
非常感谢,
马可