Changes
Title
unchanged
How to use Multiple instances of the same model in the same form
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
Multiple instances of the same model in the same form, Multiple instances of the same model, Two instances of the same model
Content
changed
[...]
// Set attribute for user data
$model->attributes=$_POST['User'];
// Validate all three model
$valid=$addressModel_1->validate();
$valid=$addressModel_2->validate() && $valid;
$valid=$model->validate() && $valid;
if($valid)[...]
// Validate all three model
$valid=$addressModel_1->validate();
$valid=$addressModel_2->validate() && $valid;
$valid=$model->validate() && $valid;
if($valid)
{
$addressModel_1->save();
$addressModel_2->save();[...]