aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_country_helper.rb
diff options
context:
space:
mode:
authorSven Fuchs <svenfuchs@artweb-design.de>2008-07-16 11:30:57 -0700
committerSven Fuchs <svenfuchs@artweb-design.de>2008-07-16 11:30:57 -0700
commit842917dea0cfdf70f158a312cc1f77f769791d8c (patch)
tree3a66555996dee9a7242027b10d85a3050582470a /actionpack/lib/action_view/helpers/form_country_helper.rb
parent428b77debdab27c0bd73ec87bda8914d6acdfd3e (diff)
downloadrails-842917dea0cfdf70f158a312cc1f77f769791d8c.tar.gz
rails-842917dea0cfdf70f158a312cc1f77f769791d8c.tar.bz2
rails-842917dea0cfdf70f158a312cc1f77f769791d8c.zip
moving country helpers from form_options_helper to form_country_helper again
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_country_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_country_helper.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/helpers/form_country_helper.rb b/actionpack/lib/action_view/helpers/form_country_helper.rb
index b2d2b7741f..84e811f61d 100644
--- a/actionpack/lib/action_view/helpers/form_country_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_country_helper.rb
@@ -3,9 +3,10 @@ require 'action_view/helpers/form_options_helper'
module ActionView
module Helpers
module FormCountryHelper
+
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
- InstanceTag.new(object, method, self, nil, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
+ InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
end
# Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
@@ -15,17 +16,17 @@ module ActionView
# NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
def country_options_for_select(selected = nil, priority_countries = nil)
country_options = ""
-
+
if priority_countries
country_options += options_for_select(priority_countries, selected)
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
end
-
+
return country_options + options_for_select(COUNTRIES, selected)
end
private
-
+
# All the countries included in the country_options output.
COUNTRIES = ["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola",
"Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria",
@@ -63,8 +64,7 @@ module ActionView
"Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom",
"United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela",
"Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis and Futuna", "Western Sahara",
- "Yemen", "Zambia", "Zimbabwe"] unless const_defined?("COUNTRIES")
-
+ "Yemen", "Zambia", "Zimbabwe"] unless const_defined?("COUNTRIES")
end
class InstanceTag #:nodoc:
@@ -80,7 +80,13 @@ module ActionView
options, value
), html_options
)
- end
+ end
+ end
+
+ class FormBuilder
+ def country_select(method, priority_countries = nil, options = {}, html_options = {})
+ @template.country_select(@object_name, method, priority_countries, objectify_options(options), @default_options.merge(html_options))
+ end
end
end
end \ No newline at end of file