<% def generate_id(form, input_name) "#{form.object_name.gsub(/[\[\]]/, '[' => '_', ']' => '_')}#{input_name}" end %>
<%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} given-name", autofocus: true, id: generate_id(form, "firstname"), label: I18n.t("spree.first_name"), name: "#{form.object_name}[firstname]", required: true, value: address.firstname ) %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} family-name", id: generate_id(form, "lastname"), label: I18n.t("spree.last_name"), name: "#{form.object_name}[lastname]", required: false, value: address.lastname ) %> <% if Spree::Config[:company] %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} organization", id: :todo, label: I18n.t("spree.company"), name: "#{form.object_name}[company]", value: address.company ) %> <% end %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} address-line1", id: generate_id(form, "address1"), label: I18n.t("spree.street_address"), name: "#{form.object_name}[address1]", required: true, value: address.address1 ) %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} address-line2", id: generate_id(form, "address2"), label: I18n.t("spree.street_address_2"), name: "#{form.object_name}[address2]", value: address.address2 ) %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} address-level2", id: generate_id(form, "city"), label: I18n.t("spree.city"), name: "#{form.object_name}[city]", required: true, value: address.city ) %> <%= render( "spree/components/forms/inputs/collection_select", autocomplete: "#{address_type} country-name", collection: available_countries, form: form, id: generate_id(form, "country_id"), input_class: "js-trigger-state-change", label: t("spree.country"), method: :country_id, required: true, state_container: "##{address_type} .js-address-fields", text_method: :name, value_method: :id ) %> <% if Spree::Config[:address_requires_state] %> <% have_states = !address.country.states.empty? %> <% end %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} postal-code", id: generate_id(form, "zipcode"), label: I18n.t("spree.zip"), name: "#{form.object_name}[zipcode]", required: address.require_zipcode?, value: address.zipcode ) %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} home tel", id: generate_id(form, "phone"), label: I18n.t("spree.phone"), name: "#{form.object_name}[phone]", required: address.require_phone?, type: :tel, value: address.phone ) %> <% if Spree::Config[:alternative_shipping_phone] %> <%= render( "spree/components/forms/inputs/text", autocomplete: "#{address_type} tel", id: generate_id(form, "alternative_phone"), label: I18n.t("spree.alternative_phone"), name: "#{form.object_name}[alternative_phone]", type: :tel, value: address.alternative_phone ) %> <% end %>