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 などの子クラスを選択する必要があります。
次に、ページがリロードされ、正しいフォームが表示されます。
2番目の選択フィールドに表示するための継承/子クラスを取得するDoctrineの関数はありますか?
(例: Rennfahrzeuge には Tourenwagen、...、...、Sonstige があり、Karts には TonyKart、...、...、Sonstige があります)
その後、次のような割り当てられたフォーム クラスを動的に作成できます。
$chooseMode = $request->getParameter('chooseMode').'Form';
$modeFormClass = new $chooseMode();
または、親フォーム クラスに適切なモデルを設定することだけを考えました。
あなたの考えは何ですか?提案や助けをいただければ幸いです:-)
どうもありがとう、
マルコ