This project is archived and is in readonly mode.
support of html Attributes for options_for_select
Reported by Joshaven Potter | March 7th, 2009 @ 07:15 PM | in 3.x
Regarding: ActionView::Helpers::FormOptionsHelper options_for_select
The options_for_select FormOptionsHelper method could easily support html attributes, however it currently ignores them. I recommend supporting html attributes when calling the function with an Array containing name, value & hash of attributes.
I used the attached modification to support this feature... they are not designed to be run by themselves but to be added to form_options_helper.rb
The attached file also contains new tests to ensure proper operation of the method.
Comments and changes to this ticket
-
Steve St. Martin April 15th, 2010 @ 09:29 PM
- Assigned user set to Ryan Bigg
Verified on 2.3.5, Please submit a valid patch http://guides.rails.info/contributing_to_rails.html#create-a-patch.
Can be marked as incomplete.
-
Ryan Bigg April 15th, 2010 @ 10:40 PM
- State changed from new to incomplete
Seems like a great patch. Please format this patch in the suggested way.
-
Marc Lainez May 6th, 2010 @ 01:37 PM
- Tag changed from action_view, feature, feature_request, form_options_helper to action_view, feature, feature_request, form_options_helper, patch
Useful indeed Joshaven, I made a patch including your changes and tests. Tell me if it needs to be reworked.
-
Joshaven Potter May 6th, 2010 @ 02:48 PM
Sorry, I have not been working with Rails much for the last few months. I am happy that you guys are taking this and running with it!
-
Dan Pickett May 9th, 2010 @ 06:13 PM
- Tag changed from action_view, feature, feature_request, form_options_helper, patch to action_view, bugmash, feature, feature_request, form_options_helper, patch
Marc, was the patch you supplied made against master or 2-3-stable?
Can bugmashers apply this and check if it cleanly applies to master?
-
Jared Pace May 14th, 2010 @ 03:41 PM
We verified this patch against master, and noticed there were no docs added. So we added some documentation and have attached a revised patch.
One note of feedback: the method
html_attributes_from
is pretty complicated, and we thought it should be simplified if at all possible. Also the fact that Marc's original code added threeNOTE
s smells a little bad to us, maybe that could be cleaned up with explaining methods?- Rob and Jared @ Relevance
-
Santiago Pastorino May 15th, 2010 @ 12:33 AM
- State changed from incomplete to open
- Assigned user changed from Ryan Bigg to José Valim
Tickets should be new or open if they are being discussed
-
José Valim May 15th, 2010 @ 07:53 AM
@Jared, I agree. The code can be improved and the to_a call should also be removed (use Array.wrap instead). Anyone willing to improve it, can consider that Jared's patch above will be applied and you can apply your fixes on top of it.
-
pleax May 15th, 2010 @ 01:44 PM
I’ve attached a patch with few more test-cases and slightly different approach to implementation.
-
Anil Wadghule May 15th, 2010 @ 04:32 PM
+1 Patch applies cleanly. Tests pass. It is an useful feature to have.
-
jslag May 15th, 2010 @ 08:43 PM
+1 to pleax's 2165-html_attributes_in_options_for_select.diff
- verified that it still applies cleanly to master
- function name 'option_html_attributes' is more internally consistent
- patching option_text_and_value to handle the potential addition of Hashes is cleaner than the original patch's changes in options_for_select
-
Neil Cook May 15th, 2010 @ 09:05 PM
+1 Patch 2165-html_attributes_in_options_for_select.diff from pleax applies cleanly. Tests pass.
-
Enrico Bianco May 15th, 2010 @ 10:59 PM
+1, applies cleanly to current master, tests pass, comprehensive tests and documentation.
-
Repository May 16th, 2010 @ 01:35 PM
(from [2dc1402417242784a738321e7edd521f8ec7ac83]) added support for html attributes in options_for_select [#2165]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/2dc1402417242784a738321e7edd52... -
José Valim May 16th, 2010 @ 01:35 PM
- State changed from open to resolved
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 2165 support of html Attributes for options_for_select (from [2dc1402417242784a738321e7edd521f8ec7ac83]) added s...