Sha256: b1872b4333572c49d895607fb81b3427a148534823c0769074b8f5b06b9e1727
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# encoding: utf-8 require "rails_country_select/version" require File.expand_path('../country_definitions', __FILE__) if defined?(Rails) && defined?(ActionView) module ActionView module Helpers module FormOptionsHelper def country_select(object, method, options = {}, html_options = {}) options[:keys] = :names unless options.has_key?(:keys) options[:values] = :nums unless options.has_key?(:values) potential = { :names => COUNTRY_NAMES, :nums => COUNTRY_NUMS, :alpha2s => COUNTRY_ALPHA2S, :alpha3s => COUNTRY_ALPHA3S } select_options = potential[options[:keys]].zip(potential[options[:values]]) InstanceTag.new(object, method, self, options.delete(:object)).to_select_tag(select_options, options, html_options) end end class FormBuilder def country_select(method, options = {}, html_options = {}) @template.country_select(@object_name, method, options.merge({:object => @object}), html_options) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_country_select-0.0.1 | lib/rails_country_select.rb |