diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-10-26 08:08:45 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-10-26 08:08:45 +0000 |
commit | e162f87964bd2f9721c415b2feb5a228e85644b6 (patch) | |
tree | 8bae8bfbdb03f34b4b1228512b6e2b973e873795 /config/initializers | |
parent | 711982b7b316ae3ff79ac5cf4d3d4525869d13c6 (diff) | |
download | redmine-e162f87964bd2f9721c415b2feb5a228e85644b6.tar.gz redmine-e162f87964bd2f9721c415b2feb5a228e85644b6.zip |
Replaces <option value=""></option> which is not HTML5 valid (#15191).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12237 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/10-patches.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 79641513e..d186bcdc4 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -91,6 +91,43 @@ end ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag || ''.html_safe } +# HTML5: <option value=""></option> is invalid, use <option value=""> </option> instead +module ActionView + module Helpers + class InstanceTag + private + def add_options_with_non_empty_blank_option(option_tags, options, value = nil) + if options[:include_blank] == true + options = options.dup + options[:include_blank] = ' '.html_safe + end + add_options_without_non_empty_blank_option(option_tags, options, value) + end + alias_method_chain :add_options, :non_empty_blank_option + end + + module FormTagHelper + def select_tag_with_non_empty_blank_option(name, option_tags = nil, options = {}) + if options.delete(:include_blank) + options[:prompt] = ' '.html_safe + end + select_tag_without_non_empty_blank_option(name, option_tags, options) + end + alias_method_chain :select_tag, :non_empty_blank_option + end + + module FormOptionsHelper + def options_for_select_with_non_empty_blank_option(container, selected = nil) + if container.is_a?(Array) + container = container.map {|element| element.blank? ? [" ".html_safe, ""] : element} + end + options_for_select_without_non_empty_blank_option(container, selected) + end + alias_method_chain :options_for_select, :non_empty_blank_option + end + end +end + require 'mail' module DeliveryMethods |