-
Notifications
You must be signed in to change notification settings - Fork 355
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 block to collection_check_boxes
and collection_radio_buttons
.
#477
Comments
Here's a specific example I'm having trouble implementing: I have a In ordinary Rails I could do this:
I can't seem to find a similarly elegant way to do this with |
Another thought I'm having is perhaps in addition to the In my case, I want the checkboxes to toggle visibility of a div elsewhere on the page, so I might do something like:
and thus each checkbox would have an attribute like In @lcreid 's example right now, I would just replace
This seems like it should be a bit easier to manage and fairly elegant. Another parameter could be permitted for |
@lcreid can you provide an example to be 100 percent compatible with your helpers? |
The Rails
collection_check_boxes
andcollection_radio_button
methods can take a block. If a block is provided, the helper yields a special builder to the block. The idea is that the programmer can format the check box or radio button more precisely in the block, if the standard format produced by the Rails helpers doesn't give the desired results.Our helpers do not take a block. We can speculate that since our helpers format the check boxes and radio buttons in a consistent and pleasing way, there's less need for the block. There may also have been a technical reason that made yielding to a block difficult. I haven't investigated enough to have an idea of that.
However, there still may arise situations in which it would be convenient to have the ability to output the controls in a block. On example would be when you want to show all the check boxes or radio buttons, but some of them need to be disabled. Another example might be to highlight certain "dangerous" check boxes or radio buttons with the "danger" colour.
Another argument in favour of providing this is simply to make our helpers more closely mimic the behaviour of the Rails helpers. I bet there are a number of cases of people wasting an hour or two trying to get a block to work with our helpers before they realized that our helper doesn't work that way.
One alternative is for programmers to code the loop themselves. This is probably not a large burden, although they would have to remember to add the
div.form-group
and the error handling in order to be 100 percent compatible with our helpers.Would we consider a pull request for this functionality if someone submitted one?
The text was updated successfully, but these errors were encountered: