Prior to this PR we just read form.errors_as_data to get a list of ValidationError instances per field for Patient and Visit. Unfortunately this strategy fell down for errors that later on cause the model to save, for example removing the year portion of the date only leaving the day and month.
This PR simplifies and extends error handling to grab all errors that occur saving patient and visit, combine them with the form validation errors and return them.
We no longer need to check if a form validation error will cause a knock on failure to save, as we'll just catch that later anyway.
For the moment we just toast each error which is quite horrible but at least gives the user ALL the information:
I've also moved the toast to the bottom of the template so they appear over the top of the rest of the page correctly.
Fixes #345 Fixes #331
Prior to this PR we just read
form.errors_as_data
to get a list ofValidationError
instances per field forPatient
andVisit
. Unfortunately this strategy fell down for errors that later on cause the model to save, for example removing the year portion of the date only leaving the day and month.This PR simplifies and extends error handling to grab all errors that occur saving patient and visit, combine them with the form validation errors and return them.
We no longer need to check if a form validation error will cause a knock on failure to save, as we'll just catch that later anyway.
For the moment we just toast each error which is quite horrible but at least gives the user ALL the information:
I've also moved the toast to the bottom of the template so they appear over the top of the rest of the page correctly.