Answer the question
In order to leave comments, you need to log in
Why is the view not rendering in Yii2?
Why doesn't the view change when I press the SUBMIT button?
The letter is created in the runtime/mail folder.
The logs say that it is redirected to thanks.php, but in fact nothing happens
Contact form code in the contact.php view
<?php $form = ActiveForm::begin(['id' => 'contact-form',
'options' => ['class' => 'contact-form page-margin-top'],]); ?>
<div class="row">
<fieldset class="column column-1-2">
<?= $form->field($model, 'name')->label(false) ?>
<?= $form->field($model, 'email')->label(false) ?>
<?= $form->field($model, 'subject')->label(false) ?>
</fieldset>
<fieldset class="column column-1-2">
<?= $form->field($model, 'body')->textArea(['rows' => 6])->label(false) ?>
</fieldset>
</div>
<div class="row margin-top-30">
<div class="column column-1-2">
<p class="description t1">Наш менеджер свяжется с Вами в ближайшее время</p>
</div>
<div class="column column-1-2 align-right">
<?= Html::submitInput('ОТПРАВИТЬ', ['class' => 'more active', 'name' => 'submit']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
//$this->redirect(Url::toRoute('/site/index'));
Yii::trace('start calculating average revenue');
return $this->render('thanks');
// Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
} else {
Yii::$app->session->setFlash('error', 'There was an error sending email.');
}
// return $this->refresh();
} else {
return $this->render('contact', [
'model' => $model,
]);
}
}
Answer the question
In order to leave comments, you need to log in
Try replacing this in the controller with:
Show like this.
// показывает файл "@app/views/site/license.php"
echo \Yii::$app->view->renderFile('@app/views/site/license.php');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question