Created
May 28, 2014 14:14
-
-
Save kapowaz/81c9e3153f799e6e13c6 to your computer and use it in GitHub Desktop.
This monstrosity comes from Spree's address form view.
This file contains 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] %> | |
<p class="field" id=<%="#{address_id}state" %>> | |
<% have_states = !address.country.states.empty? %> | |
<%= form.label :state, Spree.t(:state) %><span class='required' id=<%="#{address_id}state-required"%>>*</span><br/> | |
<% state_elements = [ | |
form.collection_select(:state_id, address.country.states, | |
:id, :name, | |
{:include_blank => true}, | |
{:class => have_states ? 'required' : 'hidden', | |
:disabled => !have_states}) + | |
form.text_field(:state_name, | |
:class => !have_states ? 'required' : 'hidden', | |
:disabled => have_states) | |
].join.gsub('"', "'").gsub("\n", "") | |
%> | |
<%= javascript_tag do -%> | |
$('#<%="#{address_id}state" %>').append("<%== state_elements %>"); | |
<% end %> | |
</p> | |
<noscript> | |
<%= form.text_field :state_name, :class => 'required' %> | |
</noscript> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment