Closed tinynumbers closed 11 years ago
+1 for this fix, implemented it in our fork too to address the same problem.
Looks good. I'd like to see this in as well, so I will test and merge this soon - as I love Formtastic. :+1:
I am experiencing a similar problem using carmen-rails with simple_form. The object support in this pull solves it.
Here is the code that ensures the persisted country is selected when the form is rendered:
<%= f.input :country_code, label: 'Country' do %>
<%= f.country_select :country_code, {object: f.object, prompt: 'Select a country'} %>
<% end %>
@CDainMiller when this is merged in, I will update the readme with a simple_form example.
Love it. Tested via simple_form & formtastic, seems fine to me. Also thanks Kevin for the validation, and for offering to update the README.
I'm faced with the following scenario:
form.input :as => :country
as the form-field for the Address countryThe Address object was not being passed through the whole field generation stack so therefore the previously-set value for the Address country was not being pre-selected in the country_select.
To fix this, I've added the ability for
country_select
to pull theobject
from theargs
in the same way thatsubregion_select
does. That way I can pass the object manually from my sub-form, e.g.: