<%= f.field_container :name do %> <%= f.label :name, Spree.t(:name) %> *
<%= f.text_field :name, class: 'fullwidth', required: true %> <% end %>
<%= f.field_container :admin_name do %> <%= f.label :admin_name, Spree.t(:internal_name) %> <%= f.text_field :admin_name, class: 'fullwidth', label: false %> <% end %>
<%= f.field_container :active do %> <% end %>
<%= f.label :address1, Spree.t(:street_address) %> <%= f.text_field :address1, class: 'fullwidth' %>
<%= f.label :city, Spree.t(:city) %> <%= f.text_field :city, class: 'fullwidth' %>
<%= f.label :address2, Spree.t(:street_address_2) %> <%= f.text_field :address2, class: 'fullwidth' %>
<%= f.label :zipcode, Spree.t(:zip) %> <%= f.text_field :zipcode, class: 'fullwidth' %>
<%= f.label :phone, Spree.t(:phone) %> <%= f.phone_field :phone, class: 'fullwidth' %>
<%= f.label :country_id, Spree.t(:country) %> <%= f.collection_select :country_id, available_countries, :id, :name, {}, { class: 'select2 fullwidth' } %>
<% if f.object.country %> <%= f.label :state_id, Spree.t(:state) %> <%= f.text_field :state_name, style: "display: #{f.object.country.states.empty? ? 'block' : 'none' };", disabled: !f.object.country.states.empty?, class: 'fullwidth state_name' %> <%= f.collection_select :state_id, f.object.country.states.sort, :id, :name, { include_blank: true }, {class: 'select2 fullwidth', style: "display: #{f.object.country.states.empty? ? 'none' : 'block' };", disabled: f.object.country.states.empty?} %> <% end %>
<% content_for :head do %> <%= javascript_include_tag 'spree/backend/address_states.js' %> <%= javascript_tag do -%> $(document).ready(function(){ $('span#country .select2').on('change', function() { update_state(''); }); }); <% end -%> <% end %>