@@ -46,7 +46,7 module ProjectsHelper | |||||
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | options = '' |
|
48 | options = '' | |
49 | options << "<option value=''></option>" if project.allowed_parents.include?(nil) |
|
49 | options << "<option value=''> </option>" if project.allowed_parents.include?(nil) | |
50 | options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) |
|
50 | options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) | |
51 | content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') |
|
51 | content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') | |
52 | end |
|
52 | end |
@@ -91,6 +91,43 end | |||||
91 |
|
91 | |||
92 | ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag || ''.html_safe } |
|
92 | ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag || ''.html_safe } | |
93 |
|
93 | |||
|
94 | # HTML5: <option value=""></option> is invalid, use <option value=""> </option> instead | |||
|
95 | module ActionView | |||
|
96 | module Helpers | |||
|
97 | class InstanceTag | |||
|
98 | private | |||
|
99 | def add_options_with_non_empty_blank_option(option_tags, options, value = nil) | |||
|
100 | if options[:include_blank] == true | |||
|
101 | options = options.dup | |||
|
102 | options[:include_blank] = ' '.html_safe | |||
|
103 | end | |||
|
104 | add_options_without_non_empty_blank_option(option_tags, options, value) | |||
|
105 | end | |||
|
106 | alias_method_chain :add_options, :non_empty_blank_option | |||
|
107 | end | |||
|
108 | ||||
|
109 | module FormTagHelper | |||
|
110 | def select_tag_with_non_empty_blank_option(name, option_tags = nil, options = {}) | |||
|
111 | if options.delete(:include_blank) | |||
|
112 | options[:prompt] = ' '.html_safe | |||
|
113 | end | |||
|
114 | select_tag_without_non_empty_blank_option(name, option_tags, options) | |||
|
115 | end | |||
|
116 | alias_method_chain :select_tag, :non_empty_blank_option | |||
|
117 | end | |||
|
118 | ||||
|
119 | module FormOptionsHelper | |||
|
120 | def options_for_select_with_non_empty_blank_option(container, selected = nil) | |||
|
121 | if container.is_a?(Array) | |||
|
122 | container = container.map {|element| element.blank? ? [" ".html_safe, ""] : element} | |||
|
123 | end | |||
|
124 | options_for_select_without_non_empty_blank_option(container, selected) | |||
|
125 | end | |||
|
126 | alias_method_chain :options_for_select, :non_empty_blank_option | |||
|
127 | end | |||
|
128 | end | |||
|
129 | end | |||
|
130 | ||||
94 | require 'mail' |
|
131 | require 'mail' | |
95 |
|
132 | |||
96 | module DeliveryMethods |
|
133 | module DeliveryMethods |
@@ -117,7 +117,7 class BoardsControllerTest < ActionController::TestCase | |||||
117 |
|
117 | |||
118 | assert_select 'select[name=?]', 'board[parent_id]' do |
|
118 | assert_select 'select[name=?]', 'board[parent_id]' do | |
119 | assert_select 'option', (Project.find(1).boards.size + 1) |
|
119 | assert_select 'option', (Project.find(1).boards.size + 1) | |
120 | assert_select 'option[value=]', :text => '' |
|
120 | assert_select 'option[value=]', :text => ' ' | |
121 | assert_select 'option[value=1]', :text => 'Help' |
|
121 | assert_select 'option[value=1]', :text => 'Help' | |
122 | end |
|
122 | end | |
123 | end |
|
123 | end |
General Comments 0
You need to be logged in to leave comments.
Login now