Simplify use of nested field helpers

This commit is contained in:
Matt-Yorkley
2021-07-31 19:28:33 +01:00
committed by Jean-Baptiste Bellet
parent cea2433c3e
commit d10899d9ea

View File

@@ -1,74 +1,66 @@
%div.checkout-substep
-# YOUR DETAILS
%div.checkout-title
= t("split_checkout.step1.your_details.title")
= f.fields :bill_address, model: @order.bill_address do |bill_address|
%div.checkout-substep
-# YOUR DETAILS
%div.checkout-title
= t("split_checkout.step1.your_details.title")
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :firstname, t("split_checkout.step1.your_details.first_name.label")
= bill_address.text_field :firstname, { placeholder: t("split_checkout.step1.your_details.first_name.placeholder") }
= f.error_message_on "bill_address.firstname"
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
= f.error_message_on "bill_address.firstname"
%div.checkout-input
= bill_address.label :lastname, t("split_checkout.step1.your_details.last_name.label")
= bill_address.text_field :lastname, { placeholder: t("split_checkout.step1.your_details.last_name.placeholder") }
= f.error_message_on "bill_address.lastname"
= f.error_message_on "bill_address.lastname"
%div.checkout-input
= f.label :email, t("split_checkout.step1.your_details.email.label")
= f.text_field :email, { placeholder: t("split_checkout.step1.your_details.email.placeholder") }
= f.error_message_on :email
%div.checkout-input
= f.label :email, t("split_checkout.step1.your_details.email.label")
= f.text_field :email, { placeholder: t("split_checkout.step1.your_details.email.placeholder") }
= f.error_message_on :email
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :phone, t("split_checkout.step1.your_details.phone.label")
= bill_address.text_field :phone, { placeholder: t("split_checkout.step1.your_details.phone.placeholder") }
= f.error_message_on "bill_address.phone"
= f.error_message_on "bill_address.phone"
%div.checkout-substep{ "data-controller": "dependant-select", "data-dependant-select-options-value": @countries_with_states }
-# BILLING ADDRESS
%div.checkout-title
= t("split_checkout.step1.billing_address.title")
%div.checkout-substep{ "data-controller": "dependant-select", "data-dependant-select-options-value": @countries_with_states }
-# BILLING ADDRESS
%div.checkout-title
= t("split_checkout.step1.billing_address.title")
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :address1, t("split_checkout.step1.billing_address.address1.label")
= bill_address.text_field :address1, { placeholder: t("split_checkout.step1.billing_address.address1.placeholder") }
= f.error_message_on "bill_address.address1"
= f.error_message_on "bill_address.address1"
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= f.label :address2, t("split_checkout.step1.billing_address.address2.label")
= f.text_field :address2, { placeholder: t("split_checkout.step1.billing_address.address2.placeholder") }
= f.error_message_on "bill_address.address2"
= f.error_message_on "bill_address.address2"
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :city, t("split_checkout.step1.billing_address.city.label")
= bill_address.text_field :city, { placeholder: t("split_checkout.step1.billing_address.city.placeholder") }
= f.error_message_on "bill_address.city"
= f.error_message_on "bill_address.city"
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :state_id, t("split_checkout.step1.billing_address.state_id.label")
= bill_address.select :state_id, @countries_with_states, { }, { "data-dependant-select-target": "select" }
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :zipcode, t("split_checkout.step1.billing_address.zipcode.label")
= bill_address.text_field :zipcode, { placeholder: t("split_checkout.step1.billing_address.zipcode.placeholder") }
= f.error_message_on "bill_address.zipcode"
= f.error_message_on "bill_address.zipcode"
%div.checkout-input
= fields_for :bill_address, @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :country_id, t("split_checkout.step1.billing_address.country_id.label")
= bill_address.select :country_id, @countries, { selected: @order.bill_address.country_id || DefaultCountry.id }, {"data-dependant-select-target": "source", "data-action": "dependant-select#handleSelectChange"}
- if spree_current_user||true
%div.checkout-input
= f.check_box :checkout_default_bill_address
= f.label :checkout_default_bill_address, t(:checkout_default_bill_address)
- if spree_current_user||true
%div.checkout-input
= f.check_box :checkout_default_bill_address
= f.label :checkout_default_bill_address, t(:checkout_default_bill_address)
%div.checkout-substep{ "data-controller": "toggle shippingmethod" }
-# DELIVERY ADDRESS