我在Ubuntu 9.10上使用Sympelony 1.3.2和Propel ORM。一個關於如何在Symfony中嵌入表單的例子
我有一個用戶資料表,其中有連接到它的許多其他表(即user_profile.id是一個FK許多其他表
我的數據庫架構看起來是這樣的:
user_profile:
_attributes: { phpName: UserProfile }
id: ~
guard_id: { type: integer, foreignTable: sf_guard_user, foreignReference: id, required: true }
address: { type: longvarchar, required: true }
vehicle_type:
_attributes: { phpName: VehicleType }
id: ~
name: { type: varchar(32), required: true }
user_vehicle:
_attributes: { phpName: UserVehicle }
id: ~
user_id: { type: integer, foreignTable: user_profile, foreignReference: id, required: true }
vehicle_type: { type: integer, foreignTable: vehicle_type, foreignReference: id, required: true }
license_plate: { type: varchar(16), required: true }
user_child:
_attributes: { phpName: UserChild }
id: ~
user_id: { type: integer, foreignTable: user_profile, foreignReference: id, required: true }
gender: { type: boolean, required: true }
name: { type: varchar(32), required: true }
我想在用戶配置文件表單中嵌入鏈接到用戶配置文件對象的其他對象,以便當我在用戶配置文件表單上執行CRUD時,相關對象(例如UserVehicle,UserJob也同樣爲CRUD時間作爲用戶簡檔對象)
我需要一個簡單的代碼片段來展示如何:
- 嵌入各種相關對象(即, UserVehicle,UserChild)爲用戶配置形式
- 創建/更新/作爲操作正在進行刪除相關的各種對象(請注意,用戶可以分配給他們