Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

При валидации падает модальное окно #329

Open
BackKot opened this issue Jun 21, 2020 · 1 comment
Open

При валидации падает модальное окно #329

BackKot opened this issue Jun 21, 2020 · 1 comment
Assignees

Comments

@BackKot
Copy link

BackKot commented Jun 21, 2020

В случае наличия ошибок при валидации внутри модального окна всегда происходит его падение.

Модель

public function rules() {
   return [
       [['phones'], 'validatePhones'],
   ];
}

public function validatePhones($attribute) {
    $this->addError($attribute, Yii::t('app', 'Ошибка'));
}

Форма

<?php $form = ActiveForm::begin(['id' => 'company-settings-form-id']); ?>

<?= $form->field($phonesModel, 'phones')->widget(MultipleInput::className(), [
        'allowEmptyList'    => false,
        'enableGuessTitle'  => true,
        'enableError' => true,
        'addButtonPosition' => MultipleInput::POS_HEADER, // show add button in the header
        'columns' => [
            [
                'name' => 'is_active',
                'type' => 'checkbox',
            ],
            [
                'name' => 'phone',
                'title' => 'Номер телефона',
                'type' => MaskedInput::className(),
                'options' => [
                    'mask' => '+7 (999) 999-99-99',
                ],
            ],
        ],
]) ?>

Контроллер

public function actionUpdate($id) {
...
        if (Yii::$app->request->isAjax && $meterDaysModel->load(Yii::$app->request->post())) {
            Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($meterDaysModel);
        }
...
@unclead
Copy link
Owner

unclead commented Jan 8, 2021

@BackKot удалось победить проблему?

@unclead unclead self-assigned this Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants