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.
The GOV.UK Design System now recommends that when part of a date is incorrect it should be individually highlighted.
This is problematic because:
The problems above mean we need to treat dates as a special case and developers will need to intercept Rails' validation and do their own.
This change adds support for showing custom error messages and highlighting the appropriate fields in the form builder. It does it by checking date fields for extra errors on the field that end with
_day
,_month
or_year
(i.e.retirement_date_year
). If they are present:govuk-input-error
class and a redProblems
payment_date
andpayment_date_year
to their object and exposes both in the form the error summary will likely link to bothDate
very early on - before the model gets hold of it to apply validation. Handling this safely and cleanly is non-trivial and beyond the scope of this libraryChanges