end
options = ''
- options << "<option value=''></option>" if project.allowed_parents.include?(nil)
+ options << "<option value=''> </option>" if project.allowed_parents.include?(nil)
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
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
assert_select 'select[name=?]', 'board[parent_id]' do
assert_select 'option', (Project.find(1).boards.size + 1)
- assert_select 'option[value=]', :text => ''
+ assert_select 'option[value=]', :text => ' '
assert_select 'option[value=1]', :text => 'Help'
end
end