Add help link options to form errors
What does this MR do and why?
Describe in detail what your merge request does and why.
Addresses #364301 (closed)
Sometimes we may want to include documentation links in model validation
errors in order to give users more information about why the error is
occurring and what actions they should take in order to resolve it. This
change allows for help_page_url
and help_link_text
to be provided as
ActiveModel options and be used to automatically append documentation
links onto the end of the ActiveModel form errors. If help_link_text
is not provided, 'Learn more.' will be used as the default text.
Example usage:
errors.add(
:key,
'cannot be used because it is known to belong to a compromised private key.',
help_page_url: Rails.application.routes.url_helpers.help_page_url('security/ssh_keys_restrictions', anchor: 'compromised-keys')
)
This will produce the message:
Key cannot be used because it is known to belong to a compromised private key. Learn more.
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.