I want to keep bilingual content. The form:
<?php $form = ActiveForm::begin(); ?> <?= $form->field($aboutLang_ru, 'title')->textInput() ?> <?= $form->field($aboutLang_ru, 'content')->textInput() ?> <?= $form->field($aboutLang_en, 'title')->textInput() ?> <?= $form->field($aboutLang_en, 'content')->textInput() ?> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> </div> <?php ActiveForm::end(); ?> And controller
public function actionCreate() { $model = new Post(); $aboutLang_ru = new PostLang(); $aboutLang_en = new PostLang(); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { $dbPost = new PostLang(); $dbPost->title = $aboutLang_ru->title; $dbPost->content = $aboutLang_ru->content; $dbPost->lang_id = ////////; $dbPost->post_id = $model->id; $dbPost->save(); } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('_form', [ 'model' => $model, 'aboutLang_ru' => $aboutLang_ru, 'aboutLang_en' => $aboutLang_en]); } } Here's how I do a brute force saving to save first from $ aboutLang_ru, and then from $ aboutLang_en? Different entries in the table and with different lang_id, but with the same post_id?