H
H
hitkorn2019-05-08 16:59:19
Yii
hitkorn, 2019-05-08 16:59:19

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

1 answer(s)
D
Dmitry, 2019-05-08
@hitkorn

Good afternoon.
Tabular input.
Working with multiple models
Working with connected data.
ps You can use this extension .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question