Permalink
Browse files

Added example of using options_for_select() with select_tag()

  • Loading branch information...
kirs committed Aug 30, 2012
1 parent f049d33 commit e01091d1964419403a71da50ca099f752fc63156
Showing with 4 additions and 0 deletions.
  1. +4 −0 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -117,6 +117,10 @@ def form_tag(url_for_options = {}, options = {}, &block)
# select_tag "destination", "<option>NYC</option><option>Paris</option><option>Rome</option>".html_safe, :disabled => true
# # => <select disabled="disabled" id="destination" name="destination"><option>NYC</option>
# # <option>Paris</option><option>Rome</option></select>
+ #
+ # select_tag "credit_card", options_for_select([ "VISA", "MasterCard" ], "MasterCard")
+ # # => <select id="credit_card" name="credit_card"><option>VISA</option>
+ # # <option selected="selected">MasterCard</option></select>
def select_tag(name, option_tags = nil, options = {})
option_tags ||= ""
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name

0 comments on commit e01091d

Please sign in to comment.