Single field validation does not run on fields when loading the form #628
Closed
Labels
area/validation
related to form validation rules/messages
fe-v4
Issues to be solved before v4 goes gold
kind/bug
Something isn't working
Description of the bug
If you're loading existing instance data, fields may appear valid even though single field validation would have marked it as invalid. This is because app-frontend will not run single field validation on fields that hasn't been changed in any way - it will just assume validation was successful.
To fix this, we might have to run server-side validation as soon as we load the instance (possibly only if instance data was found).
Steps To Reproduce
frontend-test
apptest
in the first name field, it gives an errorAttempted fix
When fixing #617, I tried fixing this problem at the same time, but my solution was problematic. What I did was extending the saga for
checkIfConditionalRulesShouldRun
to runFormLayoutActions.updateCurrentView
to update the current view to the current view (hacky!) while telling it to run page validations (and I added a parameter to skip empty field validations). This way validations would run when the page loads (because the saga forcheckIfConditionalRulesShouldRun
runs after the page loads, and after dynamically hidden fields have been hidden when the page loads).However, this leads to a breaking change (as single field validations can be set up to complain when required data is missing, and running that on the page load is quite user hostile). I found this solution kind-of hacky, so maybe this should be considered in relation to #339 (where we should investigate if we want our app to keep its state after a refresh, or if we can live with an app that behaves differently after a refresh).
The text was updated successfully, but these errors were encountered: