Код: Выделить всё
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'accept_id' cannot be null
The SQL being executed was: INSERT INTO `address` (`accept_id`, `city_id`, `street`, `house`, `name_building`, `floor`, `cabinet`) VALUES (NULL, 1, 'Дзержинского', '5', NULL, '1', 'б/н')
Код: Выделить всё
public function actionCreate()
{
$model = new Accept();
$address = new Address();
$address->accept_id = $accept->id;
if ($model->load(Yii::$app->request->post()) && $address->load(Yii::$app->request->post()) && $model->save()) {
if ($address->save()) {
$address->accept_id = $accept->id;
return $this->redirect(['view', 'id' => $model->id]);
}
}
return $this->render('create', compact('model', 'address'));
}