-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify generating form fields with labels #3745
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instead of generating the label and then a field without a label, we can directly generate a field with a label.
We were monkey-patching FoundationRailsHelper::Formbuilder, which made form customization difficult. We can inherit from it, which is the standard way of extending what an existing class does, and make our form the default one.
javierm
force-pushed
the
auto_labels
branch
2 times, most recently
from
October 6, 2019 10:41
d9e09fd
to
24c18f4
Compare
We were already using this code in translatable forms. Using it on every form means we can reduce the code we need to generate a field with a hint.
We were manually adding the attribute in many places, but not everywhere. I'm assuming adding it where we didn't have it is doing no harm.
`select_tag` creates just a select with no label, so there's no need to specify `label: false`.
Using the block syntax to generate the label with a <span> tag inside isn't necessary after upgrading foundation_rails_helpers. Before the upgrade, we couldn't do so because the <span> tag was escaped.
I'm not sure why it isn't already done by foundation's form builder. It doesn't make any sense to change an ID of a form field without changing the `for` attribute of its label.
smarques
pushed a commit
to venetochevogliamo/consul
that referenced
this pull request
Apr 29, 2020
Simplify generating form fields with labels
This was referenced Mar 25, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
There's a pattern we used to use a lot:
A year ago we decided to use this pattern instead:
Objectives
for
attribute automatically when we specify the field'sid
attributearia-describedby
attribute automatically to fields with hints<span class="checbox">
to checkbox labels