N
N
niceandriyanov2017-05-04 12:02:31
Yii
niceandriyanov, 2017-05-04 12:02:31

Yii form loading with AJAX?

Guys, help is needed.
At once I will tell badly I know yii... I have the General idea.
Task:
The form is displayed in the view file, they don’t want to set protections (captcha cuts off the traffic), they want the form to be loaded via ajax.
The ActiveForm class is used. How to make an ajax request to the server so that the form is formed using this class?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Konyukhov, 2017-05-04
@heahoh

Make an action in the controller

public function actionRenderForm(...) {
        ....
        $this->renderPartial('form',  array(...), false, true);
}
, in the main view (which is rendered by actionView or actionEdit, I don’t know about you) add jquery code to load the form, something like
(function($) { 
         $.get(".$this->createUrl('renderForm').", {...}, function(data) {
                 $('#formHolder').append(data);
         }); 
 })(jQuery)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question