how to give id with f.country_select in carmen gem

173 Views Asked by At

Hi I am using gem 'carmen-rails' In my view I have written this

<%= f.country_select :country, prompt: 'Please select a country',
                                   :id=>'curr-country' %>

but its not taking this id 'curr-country'. Please guide how to give id in this. Thanks in advance.

4

There are 4 best solutions below

1
On

Try this

<%= f.country_select :country, {priority: %w(US CA)}, {prompt: 'Please select a country'}, {:id => 'your-id'} %>

Hope this will help you.

0
On

You'll have to pass a second hash with the HTML options:

<%= f.country_select :country, 
                    { prompt: 'Please select a country' },
                    { id: 'curr-country' } %>

The carmen-rails gem doesn't document this explicitly (it is documented in code). The country_select gem, however, does provide an example of this in the Usage section of the README

0
On
 <%= f.country_select :country, {id: 'curr-country', prompt: 'Please select a country'} %>

try this

0
On
<%= f.country_select :country, {},  class: "form-control" %>

Try this one :)