All you have to do is not necessary with AJAX. In facts, it is not the best.
Ajax is good when you want to add some entries in your 'training' list.
So, I think you can implement AJAX for that, but to save the whole at one time, it is not good.
Fistly, for Ajax you need first that your main item (CV) is already initialized (id value)
Then, when you submit the form, if the id is not yet initialized, you will need anyway to send your complete form (main + N:1)
TODO :
1. Send the complete form.
2. Decrypt all this in the save() method of your controller. The controller have to work with the 2 models.
Controller :
- Save or update the main item, then get the ID of this saved object.
$modelCv->getState('cv.id');
- If save() was successfull, you can now add the individual 'training' entries, using a second model for that.
Very important : In the model in wich you will write a little bit, you must check carefully if you are dealing with new or existing items.
Read them all associated to this CV, then merge with the current posted form training entries.
(add, update, delete) You must do all this manually.
Not sure to be clear.
Can you understand the concept in main lines ?