Created
October 13, 2011 20:11
-
-
Save imustardsoft/1285365 to your computer and use it in GitHub Desktop.
actionpack-3.0.6/lib/action_view/helpers/form_tag_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select_tag(name, option_tags = nil, options = {}) | |
if Array === option_tags | |
ActiveSupport::Deprecation.warn 'Passing an array of option_tags to select_tag implicitly joins them without marking them as HTML-safe. Pass option_tags.join.html_safe instead.', caller | |
end | |
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name | |
if blank = options.delete(:include_blank) | |
if blank.kind_of?(String) | |
option_tags = "<option value=\"\">#{blank}</option>".html_safe + option_tags | |
else | |
option_tags = "<option value=\"\"></option>".html_safe + option_tags | |
end | |
end | |
content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment