Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question