Есть ajax валидация формы.
мои rules
[['passport_photos', 'oversea_passport_photos'], 'required', 'on' => 'vip'],
[['oversea_passport_photos', 'passport_photos'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg', 'maxFiles' => 10]
контроллер
$model = new Client();
$model->scenario = 'vip';
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
и форма
<?php $form = ActiveForm::begin([
'action' => '/order/default/vip-form',
'enableAjaxValidation' => true,
'enableClientValidation' => false,
'options' => [ 'enctype' => 'multipart/form-data']
]); ?>
<?= $form->field($model, 'passport_photos[]' )->widget(FileInput::className(), [
'options' => [
'multiple' => true,
'accept' => 'image/*'
],
'pluginOptions' => [
'allowedFileExtensions'=>[ 'jpg', 'png'],
'uploadUrl' => 'false',
'maxFileCount' => 10,
'initialPreviewAsData' => true,
'overwriteInitial' => false,
'showRemove' => false,
'showUpload' => false,
'fileActionSettings' => [
'showUpload' => false
]
]
]) ?>
<?= $form->field($model, 'oversea_passport_photos[]' )->widget(FileInput::className(), [
'options' => [
'multiple' => true,
'accept' => 'image/*'
],
'pluginOptions' => [
'allowedFileExtensions'=>[ 'jpg', 'png'],
'uploadUrl' => 'false',
'maxFileCount' => 10,
'initialPreviewAsData' => true,
'overwriteInitial' => false,
'showRemove' => false,
'showUpload' => false,
'fileActionSettings' => [
'showUpload' => false
]
]
]) ?>
<?= Html::submitButton(Yii::t('layout', 'signup'), ['class' => 'btn btn-submit']) ?>
<?php $form::end(); ?>
проблема в том, что не валидирует нормально ети поля, как исправить?