mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
#2417 Possibility to specify dataType for $.ajax call in yii.activeForm.js
This commit is contained in:
@ -45,7 +45,9 @@
|
||||
// function ($form, attribute, messages)
|
||||
afterValidate: undefined,
|
||||
// the GET parameter name indicating an AJAX-based validation
|
||||
ajaxVar: 'ajax'
|
||||
ajaxVar: 'ajax',
|
||||
// the type of data that you're expecting back from the server
|
||||
ajaxDataType: 'json'
|
||||
};
|
||||
|
||||
var attributeDefaults = {
|
||||
@ -301,7 +303,7 @@
|
||||
url: data.settings.validationUrl,
|
||||
type: $form.prop('method'),
|
||||
data: $form.serialize() + extData,
|
||||
dataType: 'json',
|
||||
dataType: data.settings.ajaxDataType,
|
||||
success: function (msgs) {
|
||||
if (msgs !== null && typeof msgs === 'object') {
|
||||
$.each(data.attributes, function () {
|
||||
|
@ -103,6 +103,10 @@ class ActiveForm extends Widget
|
||||
* @var string the name of the GET parameter indicating the validation request is an AJAX request.
|
||||
*/
|
||||
public $ajaxVar = 'ajax';
|
||||
/**
|
||||
* @var string the type of data that you're expecting back from the server.
|
||||
*/
|
||||
public $ajaxDataType = 'json';
|
||||
/**
|
||||
* @var string|JsExpression a JS callback that will be called when the form is being submitted.
|
||||
* The signature of the callback should be:
|
||||
@ -187,6 +191,7 @@ class ActiveForm extends Widget
|
||||
'successCssClass' => $this->successCssClass,
|
||||
'validatingCssClass' => $this->validatingCssClass,
|
||||
'ajaxVar' => $this->ajaxVar,
|
||||
'ajaxDataType' => $this->ajaxDataType,
|
||||
];
|
||||
if ($this->validationUrl !== null) {
|
||||
$options['validationUrl'] = Html::url($this->validationUrl);
|
||||
|
Reference in New Issue
Block a user