Hide validation errors on dependent fields emptied by a dependency change - #62
Open
Amoifr wants to merge 1 commit into
Open
Hide validation errors on dependent fields emptied by a dependency change#62Amoifr wants to merge 1 commit into
Amoifr wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #50
When a dependency changes, the UI re-renders its dependent field emptied. The submitted stale value was already handled for transformation failures: the error is cleared and moved to the hidden
__dynamic_errorfield, so nothing is rendered but the form stays invalid.Constraint violations were not: returning to a previous option submits the dependent field empty, and a
NotBlankviolation popped up on a field the user never got to fill (the error shown in the issue's video).This applies the same treatment to violations: when a dependency's submitted data differs from its initial data and the dependent field was submitted empty, its errors are cleared and the hidden error keeps the form invalid. Errors still render when the dependency did not change: submitting the initial value with an empty dependent field is a real mistake, covered by a test.
Ships functional tests on a new fixture form carrying a
NotBlankconstraint (symfony/validatoradded to require-dev), walking the exact A / B / A flow from the issue's video.