gunndabad / govuk-frontend-aspnetcore

ASP.NET Core integration for GOV.UK Design system
MIT License
30 stars 8 forks source link

Don't use ModelState to determine if page has errors #272

Closed gunndabad closed 1 year ago

gunndabad commented 1 year ago

Up until now, we've used the presence of errors within ModelState to know whether we should prepend 'Error: ' to the page title. However, we don't require that errors go into ModelState; they could be explicitly rendered by using the appropriate -error-message tag helpers.

This change moves to using a ViewData entry to know whether page has errors. The two error summary-producing tag helpers have been updated to set this to true so effectively if the page has an error summary component we infer the page has errors. There's also a pair of public extension methods to get and set this ViewData value, respectively.