symfony1 - dynamically embedding forms -
i trying add embedding forms dynamically using single table in schema.
what mean is, in sfguarduserprofile
table, have numerous fields determine user is, i.e. practice_id, nurse_id, patient_id
so, in mind, trying dynamically add nurses practices.
i have practice form, extends sfguarduseradminform
, extends sfguarduser
, can username, password etc stored in sfguarduser
table.
within practiceform
embedding practiceprofileform
, displays fields need sfguarduserprofile
table. hope following...
this works fine , see fields both tables.
now, bit unsure how do: embedding nurses. particularly unsure how this, practices , nurses saved in same table.
practiceform
class practiceform extends sfguarduseradminform { public function configure() { $form = new practiceprofileform($this->getobject()->getprofile()); $this->embedform('profile', $form); } }
i have nurseform, again extends sfguarduser
, embeds nurseprofileform, extends sfguarduserprofile
fields need.
nurseform
class dentistform extends sfguarduseradminform { public function configure() { $profileform = new nurseprofileform($this->object->profile); $this->embedform('profile', $profileform); {
}
my schema.yml follows:
sfguarduserprofile: actas: timestampable: ~ columns: user_id: type: integer(11) notnull: true default: unsigned: false primary: false unique: false autoincrement: false email_new: type: string(255) unique: true firstname: type: string(255) lastname: type: string(255) practice_id: type: integer(11) nurse_name: type: varchar(255) practice_name: type: varchar(255) practice_type: type: varchar(255) validate_at: type: timestamp validate: type: string(33) relations: user: class: sfguarduser foreign: id local: user_id type: 1 ondelete: cascade foreigntype: 1 foreignalias: profile practice: class: sfguarduserprofile foreign: id local: practice_id type: 1 ondelete: cascade indexes: validate: fields: [validate]
is there easy way achieve adding these nurses dynamically schema/forms have using doctrine/sf1.4?
manay thanks
i highly suggest rethink schema first. need store entities in 1 table?
instead, have different entities (classes) specific fields relate sfguarduser. example:
nurse: columns: account_id: integer(4) name: string(255) ... relations: account: class: sfguarduser local: account_id foreign: id type: 1 foreigntype: 1
then, can embed nurse relation in sfguarduserform:
class sfguarduserform { public function configure() { $this->embedrelation('nurse'); } }
or, other way around:
class nurseform { public function configure() { $this->embedrelation('account'); } }
and same other entities. if feel however, enities pretty same, can have @ doctrine's inheritance, though frowned upon.
Comments
Post a Comment