Sha256: a013190b5a26a1f9e018a22f77b7e07bdf63bc77426dda5bb3ea50230b0ab993

Contents?: true

Size: 1.25 KB

Versions: 13

Compression:

Stored size: 1.25 KB

Contents

module ActionView
  module Helpers
    class FormBuilder
      def country_select(method, priority_or_options = {}, options = {}, html_options = {})
        if Hash === priority_or_options
          html_options = options
          options = priority_or_options
        else
          options[:priority_countries] = priority_or_options
        end

        @template.country_select(@object_name, method, objectify_options(options), @default_options.merge(html_options))
      end
    end

    module FormOptionsHelper
      def country_select(object, method, options = {}, html_options = {})
        CountrySelect.new(object, method, self, options.delete(:object)).render(options, html_options)
      end
    end

    class CountrySelect < InstanceTag
      include ::CountrySelect::TagHelper

      def render(options, html_options)
        @options = options
        @html_options = html_options

        if self.respond_to?(:select_content_tag)
          select_content_tag(country_option_tags, @options, @html_options)
        else
          html_options = @html_options.stringify_keys
          add_default_name_and_id(html_options)
          content_tag(:select, add_options(country_option_tags, options, value(object)), html_options)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
country_select-4.0.0 lib/country_select/rails3/country_select_helper.rb
country_select-3.1.1 lib/country_select/rails3/country_select_helper.rb
country_select-3.1.0 lib/country_select/rails3/country_select_helper.rb
country_select-3.0.0 lib/country_select/rails3/country_select_helper.rb
country_select-2.5.2 lib/country_select/rails3/country_select_helper.rb
country_select-2.5.1 lib/country_select/rails3/country_select_helper.rb
country_select-2.5.0 lib/country_select/rails3/country_select_helper.rb
country_select-2.4.0 lib/country_select/rails3/country_select_helper.rb
country_select-2.3.0 lib/country_select/rails3/country_select_helper.rb
country_select-2.2.0 lib/country_select/rails3/country_select_helper.rb
country_select-2.1.1 lib/country_select/rails3/country_select_helper.rb
country_select-2.1.0 lib/country_select/rails3/country_select_helper.rb
country_select-2.0.1 lib/country_select/rails3/country_select_helper.rb