控制器中的以下代码似乎有错误,这会避免像这样的功能
这两个模型的var_dump似乎没问题。属性按预期构成。任何想法,我做错了什么?
这是控制器的代码
public function actionUpdate($id) {
try {
$model = new Bewerber();
$behavior = new \common\wsl_components\Wsl_Blameable_Behavior();
$aktualisiert_von = $behavior->get_User_Person_Id();
if (Yii::$app->request->post('_asnew') != '1') {
$model = $this->findModel($id);
}
$model_person = Person::findOne($model->id_person);
if (!$model || !$model_person) {
throw new NotFoundHttpException("The user has no profile.");
}
$model->aktualisiert_von = $aktualisiert_von;
$model_person->aktualisiert_von = $aktualisiert_von;
$model->scenario = 'update';
$model_person->scenario = 'update';
if (Model::loadMultiple([$model, $model_person], Yii::$app->request->post())) {
$isValid = $model->validate();
var_dump($model->getErrors());
$isValid = $model_person->validate() && $isValid;
if ($isValid) {
$model->saveAll(false);
$model_person->saveAll(false);
}
$model->avatar = UploadedFile::getInstances($model, 'avatar');
if ($model->upload()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
'model_person'
]);
}
} catch (\Exception $error) { //fange den schweren MySQL-Fehler ab
$go_back = "bewerber";
\common\wsl_components\error_handling::error($error, $go_back);
}
}

条件:
if (Model::loadMultiple([$model, $model_person], Yii::$app->request->post()))
将是假的。任何想法,为什么?