Reputation: 10224
I'm using ActiveAdmin (which uses Formtastic) and the iso-3166-country-select plugin for country select menus.
I would like for the plugin to include a blank option first, in case the user forgets to select a country, it will get a validation error. But then way it's setup right now, Australia is in the top of the list, so if the user forgets to setup the country, Australia is setup as their country.
The plugin has some priority countries setup such as Australia, Canada, United Kingdom and United States and I would like to change the priority countries, but I can't find anywhere of how they set these countries up as priority. The code has some comments to I tried adding a priority_countries array but couldn't make it work. I'm thinking that it's because probably Formtastic or ActiveAdmin set them up somewhere else.
I simply have this in the activeadmin file
f.inputs "Company Contact Details" do
f.input :address
f.input :city
f.input :state
f.input :postal_code
f.input :country
f.input :business_phone
f.input :business_phone_2
end
Upvotes: 2
Views: 2593
Reputation: 180
I'm using an updated version of the country_select plugin named localized_country_select. This plugin allows you to include a blank and set priority countries. It also does country codes. It is a very useful plugin, you might consider updating to this one to get it working with ActiveAdmin. Here is a code snippet from my project.
f.inputs "Place Information" do
f.input :longitude
f.input :latitude
f.input :address
f.input :city
f.input :country,
:include_blank => 'Please choose...',
:priority_countries => ['US', 'CA', 'MX', 'GB', 'FR']
end
To install plugin, remove the previous country_select plugin then:
rails plugin install git://github.com/RainerBlessing/localized_country_select.git
The plugin code is available here: https://github.com/RainerBlessing/localized_country_select
And more info about the plugin here: http://www.restafari.org/localized-country-select.html
Upvotes: 5