I will try that, it is a multi model saving function, I will look into it.
While we’re at it, there are parts of form which are loaded when user clicks button (ajax), and new model instances are added into an array of models. When there is an error on form and page gets refreshed (just like datepicker) all model data that is entered into ajax loaded parts of form disappears.
Is this something like this:
$model1 = new car();
$model2 = new tyre();
$donations[] = new carparts(); //to this array I add by calling and ajax from client side
...
$valid = model1->validate();
$valid = $valid && model2->validate();
if($valid){
model1->save()
model2->save()
...
//also parts loaded via ajax into a array of models
foreach($donations as $donation)
{
if($donation->validate())
$donation->save();
}
}