This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
generated from cds-snc/.github
-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
This file contains 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
timarney
approved these changes
Nov 25, 2019
438e539
to
6f6d999
Compare
timarney
reviewed
Nov 25, 2019
jneen
reviewed
Nov 25, 2019
errors: errorArray2ErrorObject(errors), | ||
}) | ||
req.session.flashmessage = errorArray2ErrorObject(errors) | ||
return res.redirect('back') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the code that checks this flash message? I think we need to load it into res.locals.errors
for the form-control errors to work.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Currently when posting a form with incomplete data, the validation helper takes over and re-renders the form with errors in place from the post route. This causes some problems, and is, I think, the root of the issue in #103
This will instead flash the error messages to the session, then redirect back to the form. Since the form re-renders as a regular GET request, it will have everything a GET request should have available to it. So this also solves the problem of page-specific js being lost on validation errors.
Had to adjust the test as well, since the response on an incomplete form request is now a 302 redirect instead of a 200 OK.