Answer the question
In order to leave comments, you need to log in
Yii2 How to store multiple values in a linked table?
Good afternoon.
I started to learn Yii2 and I can't figure out how to store multiple values in an intermediate table.
At the moment, I save via link(), but as far as I understand, only 1 value can be saved this way.
public function actionUpdate($id)
{
$model = Hosts::findOne($id);
if ($model->load(Yii::$app->request->post())) {
$hosts = Yii::$app->request->post("Hosts");
$platforms = Platforms::findOne($hosts['platforms']);
$model->link('platforms', $platforms);
$model->save();
return $this->redirect(['view', 'id' => $model->id]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question