public function actionUpdateForm() { $existingPeople = Yii::app()->getRequest()->getPost('people', []); $newPeople = Yii::app()->getRequest()->getPost('new-people', []); $errors = array_merge(Human::validateHumanData($existingPeople), Human::validateHumanData($newPeople, true)); if (empty($errors)) { Human::removePeople(); $people = array_merge($newPeople, $existingPeople); foreach ($people as $human) { if (trim($human['firstName']) != '' && trim($human['surname']) != '') { $humanModel = new Human(); $humanModel->attributes = $human; $humanModel->create(!is_null($humanModel->id) ? $humanModel->id : null); } } } $this->actionIndex(true, $errors); }