Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
97 lines (85 sloc) 3.98 KB
<% address_id = address_type.chars.first %>
<div class="inner" data-hook=<%="#{address_type}_inner" %>>
<div class="field field-required" id=<%="#{address_id}firstname" %>>
<%= form.label :firstname, t('spree.first_name') %>
<%= form.text_field :firstname, class: 'required', autocomplete: address_type + ' given-name', required: true, autofocus: true %>
</div>
<div class="field" id=<%="#{address_id}lastname" %>>
<%= form.label :lastname, t('spree.last_name') %>
<%= form.text_field :lastname, autocomplete: address_type + ' family-name' %>
</div>
<% if Spree::Config[:company] %>
<div class="field" id=<%="#{address_id}company" %>>
<%= form.label :company, t('spree.company') %>
<%= form.text_field :company, autocomplete: address_type + ' organization' %>
</div>
<% end %>
<div class="field field-required" id=<%="#{address_id}address1" %>>
<%= form.label :address1, t('spree.street_address') %>
<%= form.text_field :address1, class: 'required', autocomplete: address_type + ' address-line1', required: true %>
</div>
<div class="field" id=<%="#{address_id}address2" %>>
<%= form.label :address2, I18n.t('spree.street_address_2') %>
<%= form.text_field :address2, autocomplete: address_type + ' address-line2' %>
</div>
<div class="field field-required" id=<%="#{address_id}city" %>>
<%= form.label :city, t('spree.city') %>
<%= form.text_field :city, class: 'required', autocomplete: address_type + ' address-level2', required: true %>
</div>
<div class="field field-required" id=<%="#{address_id}country" %>>
<%= form.label :country_id, t('spree.country') %>
<span id=<%="#{address_id}country-selection" %>>
<%= form.collection_select :country_id, available_countries, :id, :name, {},
class: 'required',
autocomplete: address_type + ' country-name',
required: true
%>
</span>
</div>
<% if Spree::Config[:address_requires_state] %>
<div class="field field-required" id=<%="#{address_id}state" %>>
<% have_states = !address.country.states.empty? %>
<%= form.label :state, t('spree.state') %>
<span class="js-address-fields" style="display: none;">
<%=
form.collection_select(
:state_id, address.country.states, :id, :name,
{include_blank: true},
{
class: have_states ? 'required' : '',
style: have_states ? '' : 'display: none;',
disabled: !have_states,
autocomplete: address_type + ' address-level1',
})
%>
<%=
form.text_field(
:state_name,
class: !have_states ? 'required' : '',
style: have_states ? 'display: none;' : '',
disabled: have_states,
autocomplete: address_type + ' address-level1',
)
%>
</span>
<noscript>
<%= form.text_field :state_name, class: 'required', autocomplete: address_type + ' address-level1', required: true %>
</noscript>
</div>
<% end %>
<div class="field <%= 'field-required' if address.require_zipcode? %>" id=<%="#{address_id}zipcode" %>>
<%= form.label :zipcode, t('spree.zip') %>
<%= form.text_field :zipcode, class: "#{'required' if address.require_zipcode?}", autocomplete: address_type + ' postal-code', required: true %>
</div>
<div class="field <%= 'field-required' if address.require_phone? %>" id=<%="#{address_id}phone" %>>
<%= form.label :phone, t('spree.phone') %>
<% phone_hash = address.require_phone? ? { class: 'required', required: true } : {} %>
<%= form.phone_field :phone, phone_hash.merge({ autocomplete: address_type + ' home tel' }) %>
</div>
<% if Spree::Config[:alternative_shipping_phone] %>
<div class="field" id=<%="#{address_id}altphone" %>>
<%= form.label :alternative_phone, t('spree.alternative_phone') %>
<%= form.phone_field :alternative_phone, autocomplete: address_type + ' tel'%>
</div>
<% end %>
</div>