Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/carmen/rails/action_view/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,20 @@ def to_region_select_tag(parent_region, options = {}, html_options = {})
end
end

if Rails::VERSION::MAJOR == 4
if [4, 5].include? Rails::VERSION::MAJOR
module Tags
class Base
def to_region_select_tag(parent_region, options = {}, html_options = {})
html_options = html_options.stringify_keys
add_default_name_and_id(html_options)
options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options)

value = options[:selected] ? options[:selected] : value(object)
if (Rails::VERSION::MAJOR == 4 && !select_not_required?(html_options)) ||
(Rails::VERSION::MAJOR == 5 && placeholder_required?(html_options))
raise ArgumentError, "include_blank cannot be false for a required field." if options[:include_blank] == false
options[:include_blank] ||= true unless options[:prompt]
end

value = options[:selected] ? options[:selected] : value
priority_regions = options[:priority] || []
opts = add_options(region_options_for_select(parent_region.subregions, value,
:priority => priority_regions),
Expand Down