Add country select #23

Merged
merged 1 commit into from Feb 7, 2013

Projects

None yet

4 participants

@ghost

This adds a very basic country select that wraps the country_select with the correct markup.

I'm sure there is something that could make it better, but for my use (default, no options) it works just fine.

Also it is nicer then getting an exception since the builder has nothing when you have a field called country.

@kevinelliott

I'd like to see this merged!

@jibiel

Trying your master with carmen and

<%= f.input :home, :as => :country %>

gives me Formtastic::UnknownInputError. What's the API for this?

@sodabrew
Collaborator

@jibiel @nicholashubbard Could you update your patch and confirm if you think it's ready to merge?

@rhomeister

Try:

module FormtasticBootstrap
  module Inputs
    class CountryInput < Formtastic::Inputs::CountryInput
      include Base

      def to_html
        bootstrap_wrapping do
          builder.country_select(method, priority_countries, input_options, input_html_options)
        end
      end

    end
  end
end

I added this to config/initializers/formtastic.rb and it works like a charm.

@sodabrew
Collaborator

@rhomeister is that any different than the patch? GitHub is now saying that it will merge cleanly, which means I'm ready to merge this if there are no other issues with it.

@ghost

Only difference I see is @rhomeister uses bootstrap_wrapping where as my patch uses generic_input_wrapping.

I'm not sure which is the better one to use in this case.

@rhomeister

I tried generic_input_wrapping, but got the following exception:

undefined method `generic_input_wrapping' for #<FormtasticBootstrap::Inputs::CountryInput:0x000000076bca40>
@ghost

I have updated the code in the pull request to use bootstrap_wrapping instead of generic_input_wrapping. This should be good to go now.

@sodabrew
Collaborator

Thanks! Could you squash your commits together? (git rebase -i)

@ghost

As requested they have been squashed into a single commit

@sodabrew sodabrew merged commit dbcf009 into mjbellantoni:master Feb 7, 2013
@sodabrew
Collaborator

Thank you!

@rafaels rafaels referenced this pull request Feb 15, 2013
Merged

Autoloading CountryInput #53

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