Answer the question
In order to leave comments, you need to log in
How to make yii2 form with one field and two models?
Hi all.
So I have two tables user, history.
When registering, the data is added to the user table, and I also need that when adding data to username, they are saved to the history table
<?php $form = ActiveForm::begin(['id' => 'form-signup']); ?>
<?= $form->field($model, 'username') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= Html::submitButton(Yii::t('frontend', 'Signup'), ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?>
Answer the question
In order to leave comments, you need to log in
Look towards the behavior + model for the history table. An old one for yii 1.1.x was lying around
Are you doing something like logging?
In this case, I would make a separate method and use it in models where AfterSave is needed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question