У меня есть active form
Код: Выделить всё
<?php $form = ActiveForm::begin([
'action' => ['messages/send']
]); ?>
<span class="w3-xlarge"><?= Html::encode($model->user_to) ?></span>
<?= Html::activeTextInput($model, 'message',['class' => 'w3-input w3-border w3-round']); ?>
<?= Html::activeTextInput($model, 'user_from'); ?>
<?= Html::activeTextInput($model, 'user_to'); ?>
<div class="form-group">
<?= Html::submitButton('Create', ['class' => 'btn btn-primary']) ?>
</div>
<span class="w3-xlarge"><?= Html::encode($model->user_to) ?></span>
<?php ActiveForm::end(); ?>
Код: Выделить всё
public function actionSend() {
$model = new Messages();
if($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->render('dialog',['id' => $model->user_to]);
}
return $this->render('dialog',['id' => $model->user_to]);
}
Код: Выделить всё
<?php
$model = new Messages();
$model->setUser_from($user->getId());
$model->setUser_to($id);
?>
Код: Выделить всё
<?= Html::activeTextInput($model, 'user_from'); ?>
<?= Html::activeTextInput($model, 'user_to'); ?>