enableAjaxValidation在yii2中的kartik表单构建器中不起作用

时间:2017-05-19 09:23:13

标签: yii2

我创建了三个字段,在表单对象中我启用了ajax验证。但我想在文件输入中禁用ajax验证。它没有用。

<?php
    $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'],
                'enableAjaxValidation' => true,
                'formConfig'=>['labelSpan'=>6],
                ]);
echo Form::widget([
                'model' => $model,
                'form' => $form,
                'columns' => 2,
                'attributes' => [
                'campaign_name' => ['type'=>Form::INPUT_TEXT,'enableAjaxValidation' => true,
                'options'=>['placeholder'=>'Enter campaign name']],
                'voiceFile' => ['type'=>Form::INPUT_WIDGET,
                'widgetClass'=>'kartik\file\FileInput',
                'enableAjaxValidation' => false,
                'options'=>[
                'options' => ['accept' => '.mp3,.wav,.ogg','placeholder'=>'Choose a Excel file'],'pluginOptions'=>['showPreview'=>true]
                ],
                ],]]);
echo Form::widget([
                'model' => $model,
                'form' => $form,
                'columns' => 2,
                'attributes' => [
                'description' => ['type'=>Form::INPUT_TEXT,'enableAjaxValidation' => true, 'options'=>['placeholder'=>'Enter descritption']],
                'Action' => ['type'=>Form::INPUT_RAW, 'value'=>Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary','style'=>'margin-top:25px']),],]
                ]);
ActiveForm::end();
?>

1 个答案:

答案 0 :(得分:0)

要禁用验证,您必须使用

'enableClientValidation'=>false