aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2012-08-30 21:52:22 +0300
committerKir Shatrov <shatrov@me.com>2012-08-30 21:52:22 +0300
commite01091d1964419403a71da50ca099f752fc63156 (patch)
tree9a4dbfbf56a874120508b9044782e4e23b8fc3bb
parentf049d3347751686f43ebeae0aac426010293a55b (diff)
downloadrails-e01091d1964419403a71da50ca099f752fc63156.tar.gz
rails-e01091d1964419403a71da50ca099f752fc63156.tar.bz2
rails-e01091d1964419403a71da50ca099f752fc63156.zip
Added example of using options_for_select() with select_tag()
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index ace457df2e..f16e33d08d 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -117,6 +117,10 @@ module ActionView
# 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