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

ajax validation marks inputs as invalid despite their value changed #13920

Closed
zuozp8 opened this issue Apr 4, 2017 · 0 comments
Closed

ajax validation marks inputs as invalid despite their value changed #13920

zuozp8 opened this issue Apr 4, 2017 · 0 comments
Labels
JS JavaScript related status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@zuozp8
Copy link
Contributor

zuozp8 commented Apr 4, 2017

What steps will reproduce the problem?

  • setup Yii2 project from Yii2 template
  • in views/site/contact.php change
    <?php $form = ActiveForm::begin(['id' => 'contact-form']); ?> into
    <?php $form = ActiveForm::begin(['id' => 'contact-form', 'enableAjaxValidation' => true, 'enableClientValidation' => false]); ?>
  • in controllers/SiteController.php insert
    if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
            sleep(5);
            Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
            return \yii\bootstrap\ActiveForm::validate($model);
    }

after $model = new ContactForm();

  • run ./yii serve
  • enter /index.php?r=site%2Fcontact
  • quickly fill name and subject fields, then click other field (all must be completed in 5 seconds)

What is the expected result?

Those 2 fields marked as valid

What do you get instead?

Only first field is marked as valid

Additional info

Q A
Yii version c586f19 (between 2.0.11.2 and 2.0.12)
PHP version 7.1
Operating system Ubuntu

I suspect following flow:

  • value of email field is changed
  • first validation ajax is sent with data like {'name': 'foo', 'subject':''}
  • value of subject field is changed
  • second validation ajax is sent with data like {'name': 'foo', 'subject':'foo'}
  • first validation ajax returns, marks subject field as invalid and non-dirty
  • second validation ajax returns, but there are no dirty fields, so it does nothing
@samdark samdark added the JS JavaScript related label Apr 4, 2017
@samdark samdark added this to the 2.0.14 milestone Apr 4, 2017
@samdark samdark added type:bug Bug status:to be verified Needs to be reproduced and validated. labels Feb 3, 2018
@samdark samdark modified the milestones: 2.0.14, 2.0.15 Feb 3, 2018
@machour machour modified the milestones: 2.0.16, 2.0.17 Jan 14, 2019
@samdark samdark modified the milestones: 2.0.17, 2.0.16.1 Mar 20, 2019
tim-fischer-maschinensucher added a commit to tim-fischer-maschinensucher/yii2 that referenced this issue Jul 24, 2023
tim-fischer-maschinensucher added a commit to tim-fischer-maschinensucher/yii2 that referenced this issue Sep 20, 2023
@bizley bizley closed this as completed in 2152c00 Oct 17, 2023
bizley added a commit that referenced this issue Oct 17, 2023
…dation-marks-valid-field-as-invalid

Fix #13920: Fixed erroneous validation for specific cases
samdark added a commit that referenced this issue Oct 19, 2023
* added pcntl to requirements check

* Fix #13920: Fixed erroneous validation for specific cases

* Fix #13920: Added my name to CHANGELOG.md

* trim(): Passing null to parameter #1 ($string) of type string is deprecated

* Added section about Unsafe Reflection in Security best practices doc (#19948)

Co-authored-by: Bizley <pawel.bizley@gmail.com>

* Update CHANGELOG.md

* Fixed tests.

* Fix #13920: Add unit test

* Update `bower-asset/inputmask`, `bower-asset/punycode`.

* added CHANGELOG line

* Fix order.

* fix: #19978 - Mistake in Korean translation

* fix: keep doublequote

* Do not duplicate log messages in memory

* Update framework/log/FileTarget.php

Co-authored-by: Bizley <pawel.bizley@gmail.com>

* Update concept-di-container.md

Сслка "Конфигурация приложения" была не верной, она вела на страницу "Service-locator'a"

* Update CHANGELOG.md

* release version 2.0.49.1

* prepare for next release

* Revert changes in `mimeTypes.php` from 4a1f2c6

restores #19936

* update actions/checkout to v4

* Fix mime type generator

* Added note

* Update structure-controllers.md (#20003)

добавил пропущенное слово "как"

* Update CHANGELOG.md

2.0.49.2 changelog

* release version 2.0.49.2

* prepare for next release

* New methods: BaseActiveRecord::loadRelations() and BaseActiveRecord::loadRelationsFor().

* Fixed a bug where the yii serve command would break if a custom router was supplied and it had a space in the path

* Fix `MaskedInputAsset::class`.

* Fix #19927: Fixed `console\controllers\MessageController` when saving translations to database: fixed FK error when adding new string and language at the same time, checking/regenerating all missing messages and dropping messages for unused languages

* Added 'zh' into 'framework/messages/config.php' (#19995)

---------

Co-authored-by: Tobias Munk <schmunk@usrbin.de>
Co-authored-by: Tim Fischer <tf@maschinensucher.de>
Co-authored-by: Tim Fischer <35448254+tim-fischer-maschinensucher@users.noreply.github.com>
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
Co-authored-by: Oleg Poludnenko <ua.oleg@gmail.com>
Co-authored-by: Bizley <pawel.bizley@gmail.com>
Co-authored-by: Sonia Zorba <zonia3000@gmail.com>
Co-authored-by: Tobias Munk <t.munk@herzogkommunikation.de>
Co-authored-by: Akbar Herlambang <akbar6393222@yahoo.com>
Co-authored-by: lubosdz <lubosdz@gmail.com>
Co-authored-by: Yuriy Bachevskiy <Materik-r@yandex.ru>
Co-authored-by: Robert Korulczyk <robert@korulczyk.pl>
Co-authored-by: salehhashemi1992 <81674631+salehhashemi1992@users.noreply.github.com>
Co-authored-by: PowerGamer1 <PowerGamer1@users.noreply.github.com>
Co-authored-by: Brad Bell <brad@pixelandtonic.com>
Co-authored-by: Alexandru Trandafir Catalin <alex@heavydots.com>
Co-authored-by: Nabi KaramAliZadeh <NabiKAZ@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS JavaScript related status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants