this is my create page
questions/create.php
<?php $form = ActiveForm::begin(); ?>
<br><br><br>
<?= $form->field($model, 'question')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'topic')->textInput(['maxlength' => true]) ?>
<?= $form->field($model1, 'askid')->textInput(['maxlength' => true]) ?>
<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();
askid is the field in another table askquestions
questioncontroller
public function actionCreate()
{
$model = new Questions();
$model1 = new Askquestions();
//$model1 -> load(Yii::$app->request->post());
if ($model1->load(Yii::$app->request->post())) {
//$model->user_id=Yii::$app->user->identity->id;
if($model1->save())
return $this->redirect(['index']);
} else {
return $this->render('create', [
'model' => $model, 'model1' => $model1,
]);
}
}
i have generated model and crud for askquestions table and also included class in the controller and view page but the data is not inserting in the table what would be the possible way