R
R
rommcr2015-03-15 09:56:17
Yii
rommcr, 2015-03-15 09:56:17

ActiveForm and AjaxValidation - how to dynamically change the action for form validation?

Yii2.
There is an ActiveForm that has the enableAjaxValidation = true parameter.
The script for the form, depending on certain parameters, changes the action attribute. But when trying to validate the form via ajax, the script sends an ajax request to the URL that was originally set when the page loads.
Is there any way to win this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vyachin, 2015-04-08
@rommcr

can. The URL where the validation request will go is stored here https://github.com/yiisoft/yii2/blob/master/framew... i.e. when initializing the form, if it is not explicitly passed, it will be equal to the action property. To change it at runtime

var $form = $('form'),
    $data = $form.data('yiiActiveForm');

data.settings.validationUrl = 'новый урл';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question