Hi! I have a form with a lot of models, and in my controller I want to loop through each model in oder to save them if they aren’t empty
I was doing something like this:
if ($user->load(Yii::$app->request->post()))
$user->save();
if ($animal->load(Yii::$app->request->post()))
$animal->save();
if ($bird->load(Yii::$app->request->post()))
$bird->save();
But I think it would be better to loop through each one instead of writing for each one the same, how can this be done ?
Thanks!