Skip to content

Commit

Permalink
Merge pull request #1 from reverbdotcom/erik/reverb-5.2
Browse files Browse the repository at this point in the history
Erik/reverb 5.2
  • Loading branch information
ebenoist authored Feb 9, 2021
2 parents 50ebda9 + e0abee1 commit 532847f
Showing 1 changed file with 8 additions and 3 deletions.
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] : (method(:value).arity.zero? ? value : value(object))
priority_regions = options[:priority] || []
opts = add_options(region_options_for_select(parent_region.subregions, value,
:priority => priority_regions),
Expand Down

0 comments on commit 532847f

Please sign in to comment.