Closed dsamojlenko closed 4 years ago
This is a really cool change! I'll have to integrate it with #132, but I'm missing where the integration point is - i.e. where that flash message is actually checked and rendered. cc @timarney
I think the magic happens in data.helpers.js
... when gathering the view data, it grabs anything in flash and assigns it to an errors object before passing to the view
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.