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.
What are you trying to accomplish?
A recent PR broke caption templates for certain types of form inputs, causing them not to render at all. The issue was caused by always using the input's configured
value:
to determine the caption template path, where previously only thename:
was used. In cases where thevalue:
was provided for eg. a text input, the code would look for the wrong caption template and, finding no template, would render no caption.Context
There are two input types for which disambiguating caption template paths by using the
value:
is necessary: radio button groups and check box groups (but only check box groups submitted as an array). This is because, in each of these cases, the same name is used for each check box or radio button element. In order to know which caption template to render, we also take thevalue:
into consideration when determining the caption template path. For example, a radio button group named "places" that has a child radio button with a value of "seattle" will look for a caption template named places_seattle_caption.html.erb.Integration
No changes necessary in production.
Risk Assessment
What approach did you choose and why?
Rather than use the
value:
to determine the caption template unconditionally, I added thevalues_disambiguate_template_names?
method to allInput
classes. This method is called bycaption_template_name
to determine if the caption template path should be constructed using thevalue:
argument. Doing so should preserve the behavior introduced in #3141 that allows submit buttons to be configured with a value while also only allowing value-based template caption paths to be used for the appropriate input types.Anything you want to highlight for special attention from reviewers?
Accessibility