S
S
slip312019-05-07 17:49:07
Yii
slip31, 2019-05-07 17:49:07

How to save linked model?

Standard question start
I can't figure it out. It is necessary to save a multilingual form, in which there may or may not be more than one language taken from the Lang model

$model = new Settings();
  $model_lang = new SettingsLang();
$lang_array = Lang::find()->all();

In the form, I need to make the number of fields according to the number of languages
<?php $form = ActiveForm::begin(); ?>

    <?php
    foreach ($lang_array as $key => $value) {
        echo $value->name;
        ?>
        <?= $form->field($model_lang, 'name')->textInput(['maxlength' => true]) ?>

        <?= $form->field($model_lang, 'full_name')->textInput(['maxlength' => true]) ?>

        <?= $form->field($model_lang, 'address')->textInput(['maxlength' => true]) ?>

        <?= $form->field($model_lang, 'bank_detail_bank_name')->textInput(['maxlength' => true]) ?> 
<?php } ?>
    <?= $form->field($model, 'main_email')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'license_number')->textInput(['maxlength' => true]) ?>

It's clear with model - take it and save it. How can I make model_lang dynamic so that I can save it later? Poke in the right direction, plz?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question