Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Document the usage of grouped_options_for_select with divider option

  • Loading branch information...
commit 1f0e2de8670587a75453f064cf384c2382c88526 1 parent 982ed06
@rafaelfranca rafaelfranca authored
Showing with 19 additions and 1 deletion.
  1. +19 −1 actionpack/lib/action_view/helpers/form_options_helper.rb
View
20 actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -464,7 +464,7 @@ def option_groups_from_collection_for_select(collection, group_method, group_lab
# Options:
# * <tt>:prompt</tt> - set to true or a prompt string. When the select element doesn't have a value yet, this
# prepends an option with a generic prompt - "Please select" - or the given prompt string.
- # * <tt>:delimiter</tt> - the delimiter for the options groups.
+ # * <tt>:divider</tt> - the divider for the options groups.
#
# Sample usage (Array):
# grouped_options = [
@@ -493,6 +493,24 @@ def option_groups_from_collection_for_select(collection, group_method, group_lab
# <option value="Canada">Canada</option>
# </optgroup>
#
+ # Sample usage (divider):
+ # grouped_options = [
+ # [['United States','US'], 'Canada'],
+ # ['Denmark','Germany','France']
+ # ]
+ # grouped_options_for_select(grouped_options, divider: '---------')
+ #
+ # Possible output:
+ # <optgroup label="---------">
+ # <option value="Denmark">Denmark</option>
+ # <option value="Germany">Germany</option>
+ # <option value="France">France</option>
+ # </optgroup>
+ # <optgroup label="---------">
+ # <option value="US">United States</option>
+ # <option value="Canada">Canada</option>
+ # </optgroup>
+ #
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
# wrap the output in an appropriate <tt><select></tt> tag.
def grouped_options_for_select(*args)
Please sign in to comment.
Something went wrong with that request. Please try again.