Skip to content

Rails 5 support, fix #60

Description

@kevinjbayer

If anyone else has issues getting this to work in Rails 5, I was able to get it by forking and adding this to form_helper.rb after line 223:

if Rails::VERSION::MAJOR == 5
      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]

            value = options[:selected] ? options[:selected] : value(object)
            priority_regions = options[:priority] || []
            opts = add_options(region_options_for_select(parent_region.subregions, value, 
                                                        :priority => priority_regions), 
                               options, value)
            select = content_tag("select", opts, html_options)
            if html_options["multiple"] && options.fetch(:include_hidden, true)
              tag("input", :disabled => html_options["disabled"], :name => html_options["name"], 
                           :type => "hidden", :value => "") + select
            else
              select
            end
          end
        end
      end
    end

On the line with options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options), I had to remove select_not_required? as this seems to be deprecated. Seems to work without, but not sure if it should be replaced with something else.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions