-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add basic select helper #260
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
This is intended to make way for a new simpler Select class that will implement roughly what Rails' `f.select` does. It's a bit more-flexible than `f.collection_select`, which we're wrapping here.
peteryates
force-pushed
the
add-govuk-select-helper
branch
from
April 9, 2021 10:04
2f0ad5e
to
d2156bb
Compare
The intention is to provide a more-flexible option than `#govuk_collection_select` that will support * setting the options via a block (at the expense of supplementary content) * grouped selects * configuring with an arbitrary array of values * being able to utilise Rails' `#options_for_select` for more control over the attributes of the contained options https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-options_for_select
This isn't the nicest approach as there's some repetition, but it confirms that dealing with blocks of options works correctly.
When building the options content the `#select` helper checks if the contents are groupable with: @Choices.first.respond_to?(:last) This failed because without ActiveSupport::CoreExtensions::String being included, an ActiveSupport::SafeBuffer has no `#first` method and the tests blow up.
peteryates
force-pushed
the
add-govuk-select-helper
branch
from
April 9, 2021 15:27
f7428f1
to
b95c595
Compare
These cover: * blocks * options_for_select * grouped_options_for_select
Puma doesn't always seem to exit cleanly unlike good old trusty Webrick.
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.
Currently users aren't given much flexibility by
#govuk_collection_select
, which wraps Rails'#collection_select
. This change introduces a#govuk_select
helper that wraps#select
and, as a result, offers the following advantages:#options_for_select
Remaining tasks
GOVUKDesignSystemFormbuilder::Elements::CollectionSelect
toGOVUKDesignSystemFormbuilder::Elements::Select
#govuk_select
#options_for_select
)