Created
January 23, 2012 05:23
-
-
Save radar/1660803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% if Spree::Config[:address_requires_state] %> | |
| <% have_states = !@order.ship_address.country.states.empty? %> | |
| <%= ship_form.label :state, t(:state) %><span>*</span> | |
| <noscript> | |
| <%= ship_form.text_field :state_name %> | |
| </noscript> | |
| <% state_elements = [ | |
| ship_form.collection_select(:state_id, @order.ship_address.country.states, | |
| :id, :name, | |
| {:include_blank => true}, | |
| {:class => have_states ? 'required' : 'hidden', | |
| :disabled => !have_states}) + | |
| ship_form.text_field(:state_name, | |
| :class => !have_states ? 'required' : 'hidden', | |
| :disabled => have_states) | |
| ].join.gsub('"', "'").gsub("\n", "") | |
| %> | |
| <%= javascript_tag do -%> | |
| document.write("<%== state_elements %>"); | |
| <% end %> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% if Spree::Config[:address_requires_state] %> | |
| <% have_states = !@order.ship_address.country.states.empty? %> | |
| <%= ship_form.label :state, t(:state) %><span>*</span> | |
| <noscript> | |
| <%= ship_form.text_field :state_name %> | |
| </noscript> | |
| <% state_elements = [ship_form] %> | |
| <%= javascript_tag do %> | |
| document.write("<%== state_elements %>"); | |
| <% end %> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ship_form | |
| ship_form.collection_select( | |
| :state_id, | |
| @order.ship_address.country.states, | |
| :id, | |
| :name, | |
| {:include_blank => true}, | |
| {helper1} | |
| ) + | |
| ship_form.text_field(helper2) | |
| end | |
| # What should I call this instead of helper1? | |
| # | |
| def helper1 | |
| if :class => have_states | |
| "required" | |
| else | |
| "hidden", :disabled => !have_states | |
| end | |
| end | |
| # What should I call this instead of helper2? | |
| # | |
| def helper2 | |
| :state_name | |
| if :class => !have_states | |
| "required" | |
| else | |
| "hidden", :disabled => have_states | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment