Post One To Many Relationship On Server

Hi,

I’ve three models

Profile(Id,Name)

WorkExperience(Id,profile_id)

Assignments(Id,work_experience_id)

Profile and WorkExperience has 1 to Many relationship

WorkExperience and Assignments has 1 to Many relationship

How I will post the data on the server and get the related collection of models ?

Thanks,

Faisal Nasir

A simple answer is not possible in this format, however,

Given that you already have a Profile, when you add a WorkExperience you will need to manually set the ‘profile_id’ from Profile. The same kind of thing for Assignments.work_experience_id. This should be set in actionCreate of the individual controller.

Getting the related collection would involve relations and using model()->[b]with(‘xxx’)[/]->findAll();

Hope this points in the right direction. :)

How do I render the views on for creating and then get it on form post ?

I’m using the relations but on form post it didn’t tell me which assignments are under which work experiences .

Under Profile: you can add WorkExper. You would have to got each WorkExper to enter individual assignments. Search for update/Create two models on one form.