Answer the question
In order to leave comments, you need to log in
How to make the "request a call" function. Yii2?
I'll explain the situation. There is a pop-up window, which is registered in layouts . It has 2 fields: name and phone.
How do I receive data, which controller or how in general? And where can I process it?
Yii::$app->mailer->compose('callback', [
'name' => $this->name,
'phone' => $this->phone,
])
->setFrom([Yii::$app->params['adminEmail'] => $this->name]) /* от кого */
->setTo($emailto) /* куда */
->setSubject('Заявка обратного звонка с сайта') /* имя отправителя */
->setTextBody($this->body) /* текст сообщения */
->send(); /* функция отправки письма */
Answer the question
In order to leave comments, you need to log in
Wrap the submit form in Pjax and put it in a separate view, which you render in a modal window.
In the form, specify the address for processing, for example ['/site/contact'].
In the controller, process the data and render the same form (view) [$this->renderAjax('pjax-modal-form-view.php')].
To close the modal window upon successful submission, pass an additional parameter to the view, and in the view itself add js code, something like this:
if (isset($result) && $result){
$this->registerJs("$('#myModal').hide()");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question