src/Storefront/Resources/views/storefront/component/address/address-form.html.twig line 1

  1. {% block component_address_form %}
  2.     {% block component_address_form_addressId %}
  3.         {% if data.get('id') %}
  4.             <input type="hidden"
  5.                    name="{{ prefix }}[id]"
  6.                    value="{{ data.get('id') }}">
  7.         {% endif %}
  8.     {% endblock %}
  9.     {% block component_address_form_company %}
  10.         {% if showFormCompany %}
  11.             {% if config('core.loginRegistration.showAccountTypeSelection') %}
  12.                 {% set accountTypeRequired = true %}
  13.             {% endif %}
  14.             {% if config('core.loginRegistration.showAccountTypeSelection') or prefix == "address" or prefix == "shippingAddress" or hasSelectedBusiness %}
  15.                 <div class="{% if prefix == "shippingAddress" or hasSelectedBusiness %}address-contact-type-company{% elseif prefix == "address" %}js-field-toggle-contact-type-company d-block{% else %}js-field-toggle-contact-type-company d-none{% endif %}">
  16.                     {% block component_address_form_company_fields %}
  17.                         <div class="row g-2">
  18.                             {% block component_address_form_company_name %}
  19.                                 <div class="form-group col-6">
  20.                                     {% if formViolations.getViolations("/company") is not empty %}
  21.                                         {% set violationPath = "/company" %}
  22.                                     {% elseif formViolations.getViolations("/#{prefix}/company") is not empty %}
  23.                                         {% set violationPath = "/#{prefix}/company" %}
  24.                                     {% endif %}
  25.                                     {% block component_address_form_company_name_label %}
  26.                                         <label class="form-label"
  27.                                                for="{{ idPrefix ~ prefix }}company">
  28.                                             {{ "address.companyNameLabel"|trans|sw_sanitize }}{% if prefix != "shippingAddress" and accountTypeRequired %}{{ "general.required"|trans|sw_sanitize }}{% endif %}
  29.                                         </label>
  30.                                     {% endblock %}
  31.                                     {% block component_address_form_company_name_input %}
  32.                                         <input type="text"
  33.                                                class="form-control{% if violationPath %} is-invalid{% endif %}"
  34.                                                id="{{ idPrefix ~ prefix }}company"
  35.                                                placeholder="{{ "address.companyNamePlaceholder"|trans|striptags }}"
  36.                                                name="{{ prefix }}[company]"
  37.                                                value="{{ data.get('company') }}"
  38.                                                {% if prefix != "shippingAddress" and accountTypeRequired %}required="required"{% endif %}>
  39.                                     {% endblock %}
  40.                                     {% block component_address_form_company_name_input_error %}
  41.                                         {% if violationPath %}
  42.                                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  43.                                         {% endif %}
  44.                                     {% endblock %}
  45.                                 </div>
  46.                             {% endblock %}
  47.                             {% block component_address_form_company_department %}
  48.                                 <div class="form-group col-md-6">
  49.                                     {% if formViolations.getViolations("/department") is not empty %}
  50.                                         {% set violationPath = "/department" %}
  51.                                     {% elseif formViolations.getViolations("/#{prefix}/department") is not empty %}
  52.                                         {% set violationPath = "/#{prefix}/department" %}
  53.                                     {% endif %}
  54.                                     {% block component_address_form_company_department_label %}
  55.                                         <label class="form-label"
  56.                                                for="{{ idPrefix ~ prefix }}department">
  57.                                             {{ "address.companyDepartmentLabel"|trans|sw_sanitize }}
  58.                                         </label>
  59.                                     {% endblock %}
  60.                                     {% block component_address_form_company_department_input %}
  61.                                         <input type="text"
  62.                                                class="form-control{% if violationPath %} is-invalid{% endif %}"
  63.                                                id="{{ idPrefix ~ prefix }}department"
  64.                                                placeholder="{{ "address.companyDepartmentPlaceholder"|trans|striptags }}"
  65.                                                name="{{ prefix }}[department]"
  66.                                                value="{{ data.get('department') }}">
  67.                                     {% endblock %}
  68.                                     {% block component_address_form_company_department_input_error %}
  69.                                         {% if violationPath %}
  70.                                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  71.                                         {% endif %}
  72.                                     {% endblock %}
  73.                                 </div>
  74.                             {% endblock %}
  75.                             {% block component_address_form_company_vatId %}
  76.                                 {% if prefix == 'address' and showVatIdField %}
  77.                                     <div class="form-group col-md-6">
  78.                                         {% sw_include '@Storefront/storefront/component/address/address-personal-vat-id.html.twig' with {
  79.                                             'vatIds': context.customer.vatIds
  80.                                         } %}
  81.                                     </div>
  82.                                 {% endif %}
  83.                             {% endblock %}
  84.                         </div>
  85.                     {% endblock %}
  86.                 </div>
  87.             {% endif %}
  88.         {% endif %}
  89.     {% endblock %}
  90.     {% block component_address_form_address_fields %}
  91.         <div class="row g-2">
  92.             {% block component_address_form_street %}
  93.                 <div class="form-group col-md-6">
  94.                     {% if formViolations.getViolations("/street") is not empty %}
  95.                         {% set violationPath = "/street" %}
  96.                     {% elseif formViolations.getViolations("/#{prefix}/street") is not empty %}
  97.                         {% set violationPath = "/#{prefix}/street" %}
  98.                     {% else %}
  99.                         {% set requiredMessage = "error.VIOLATION::IS_BLANK_ERROR"|trans({ '%field%': "address.streetLabel"|trans|sw_sanitize }) %}
  100.                     {% endif %}
  101.                     {% block component_address_form_street_label %}
  102.                         <label class="form-label"
  103.                                for="{{ idPrefix ~ prefix }}AddressStreet">
  104.                             {{ "address.streetLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  105.                         </label>
  106.                     {% endblock %}
  107.                     {% block component_address_form_street_input %}
  108.                         <input type="text"
  109.                                class="form-control{% if violationPath %} is-invalid{% endif %}"
  110.                                id="{{ idPrefix ~ prefix }}AddressStreet"
  111.                                placeholder="{{ "address.streetPlaceholder"|trans|striptags }}"
  112.                                name="{{ prefix }}[street]"
  113.                                value="{{ data.get('street') }}"
  114.                                data-form-validation-required
  115.                                {% if requiredMessage is defined %}data-form-validation-required-message="{{ requiredMessage }}"{% endif %}
  116.                                required="required">
  117.                     {% endblock %}
  118.                     {% block component_address_form_street_input_error %}
  119.                         {% if violationPath %}
  120.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  121.                         {% endif %}
  122.                     {% endblock %}
  123.                 </div>
  124.             {% endblock %}
  125.             {% block component_address_form_zipcode_city %}
  126.                 {% set zipcodeField %}
  127.                 {% set zipcodeValue = formViolations.getInputData()['zipcode'] ?? data.get('zipcode') %}
  128.                     {% if formViolations.getViolations("/zipcode") is not empty %}
  129.                         {% set violationPath = "/zipcode" %}
  130.                     {% elseif formViolations.getViolations("/#{prefix}/zipcode") is not empty %}
  131.                         {% set violationPath = "/#{prefix}/zipcode" %}
  132.                     {% else %}
  133.                         {% set requiredMessage = "error.VIOLATION::IS_BLANK_ERROR"|trans({ '%field%': "address.zipcodeLabel"|trans|sw_sanitize }) %}
  134.                     {% endif %}
  135.                     {% block component_address_form_zipcode_label %}
  136.                         <label class="form-label"
  137.                                for="{{ idPrefix ~ prefix }}AddressZipcode">
  138.                             {{ "address.zipcodeLabel"|trans|sw_sanitize }}<span class="d-none" id="zipcodeLabel">{{ "general.required"|trans|sw_sanitize }}</span>
  139.                         </label>
  140.                     {% endblock %}
  141.                     {% block component_address_form_zipcode_input %}
  142.                         <input type="text"
  143.                                class="form-control{% if violationPath %} is-invalid{% endif %}"
  144.                                id="{{ idPrefix ~ prefix }}AddressZipcode"
  145.                                placeholder="{{ "address.zipcodePlaceholder"|trans|striptags }}"
  146.                                name="{{ prefix }}[zipcode]"
  147.                                value="{{ zipcodeValue }}"
  148.                                data-input-name="zipcodeInput"
  149.                         >
  150.                     {% endblock %}
  151.                     {% block component_address_form_zipcode_error %}
  152.                         {% if violationPath %}
  153.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  154.                         {% endif %}
  155.                     {% endblock %}
  156.                 {% endset %}
  157.                 {% set cityField %}
  158.                     {% if formViolations.getViolations("/city") is not empty %}
  159.                         {% set violationPath = "/city" %}
  160.                     {% elseif formViolations.getViolations("/#{prefix}/city") is not empty %}
  161.                         {% set violationPath = "/#{prefix}/city" %}
  162.                     {% else %}
  163.                         {% set requiredMessage = "error.VIOLATION::IS_BLANK_ERROR"|trans({ '%field%': "address.cityLabel"|trans|sw_sanitize }) %}
  164.                         {% set violationPath = null %}
  165.                     {% endif %}
  166.                     {% block component_address_form_city_label %}
  167.                         <label class="form-label"
  168.                                for="{{ idPrefix ~ prefix }}AddressCity">
  169.                             {{ "address.cityLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  170.                         </label>
  171.                     {% endblock %}
  172.                     {% block component_address_form_city_input %}
  173.                         <input type="text"
  174.                                class="form-control{% if violationPath %} is-invalid{% endif %}"
  175.                                id="{{ idPrefix ~ prefix }}AddressCity"
  176.                                placeholder="{{ "address.cityPlaceholder"|trans|striptags }}"
  177.                                name="{{ prefix }}[city]"
  178.                                value="{{ data.get('city') }}"
  179.                                data-form-validation-required
  180.                                {% if requiredMessage is defined %}data-form-validation-required-message="{{ requiredMessage }}"{% endif %}
  181.                                required="required">
  182.                     {% endblock %}
  183.                     {% block component_address_form_city_error %}
  184.                         {% if violationPath %}
  185.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  186.                         {% endif %}
  187.                     {% endblock %}
  188.                 {% endset %}
  189.                 {% if config('core.address.showZipcodeInFrontOfCity') %}
  190.                     <div class="form-group col-md-2 col-4">
  191.                         {{ zipcodeField }}
  192.                     </div>
  193.                     <div class="form-group col-md-4 col-8">
  194.                         {{ cityField }}
  195.                     </div>
  196.                 {% else %}
  197.                     <div class="form-group col-md-4 col-8">
  198.                         {{ cityField }}
  199.                     </div>
  200.                     <div class="form-group col-md-2 col-4">
  201.                         {{ zipcodeField }}
  202.                     </div>
  203.                 {% endif %}
  204.             {% endblock %}
  205.             {% block component_address_form_additional_field1 %}
  206.                 {% if config('core.loginRegistration.showAdditionalAddressField1') %}
  207.                     {% if formViolations.getViolations("/additionalAddressLine1") is not empty %}
  208.                         {% set violationPath = "/additionalAddressLine1" %}
  209.                     {% elseif formViolations.getViolations("/#{prefix}/additionalAddressLine1") is not empty %}
  210.                         {% set violationPath = "/#{prefix}/additionalAddressLine1" %}
  211.                     {% endif %}
  212.                     <div class="form-group col-md-6">
  213.                         {% block component_address_form_additional_field1_label %}
  214.                             <label class="form-label"
  215.                                    for="{{ idPrefix ~ prefix }}AdditionalField1">
  216.                                 {{ "address.additionalField1Label"|trans|sw_sanitize }}{{ config('core.loginRegistration.additionalAddressField1Required') ? "general.required"|trans|sw_sanitize }}
  217.                             </label>
  218.                         {% endblock %}
  219.                         {% block component_address_form_additional_field1_input %}
  220.                             <input type="text"
  221.                                    class="form-control {% if violationPath %} is-invalid{% endif %}"
  222.                                    id="{{ idPrefix ~ prefix }}AdditionalField1"
  223.                                    placeholder="{{ "address.additionalField1Placeholder"|trans|striptags }}"
  224.                                    name="{{ prefix }}[additionalAddressLine1]"
  225.                                    value="{{ data.get('additionalAddressLine1') }}"
  226.                                     {{ config('core.loginRegistration.additionalAddressField1Required') ? 'required="true"' }}>
  227.                         {% endblock %}
  228.                         {% block component_address_form_additional_field1_error %}
  229.                             {% if violationPath %}
  230.                                 {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  231.                             {% endif %}
  232.                         {% endblock %}
  233.                     </div>
  234.                 {% endif %}
  235.             {% endblock %}
  236.             {% block component_address_form_additional_field2 %}
  237.                 {% if config('core.loginRegistration.showAdditionalAddressField2') %}
  238.                     {% if formViolations.getViolations("/additionalAddressLine2") is not empty %}
  239.                         {% set violationPath = "/additionalAddressLine2" %}
  240.                     {% elseif formViolations.getViolations("/#{prefix}/additionalAddressLine2") is not empty %}
  241.                         {% set violationPath = "/#{prefix}/additionalAddressLine2" %}
  242.                     {% endif %}
  243.                     <div class="form-group col-md-6">
  244.                         {% block component_address_form_additional_field2_label %}
  245.                             <label class="form-label"
  246.                                    for="{{ idPrefix ~ prefix }}AdditionalField2">
  247.                                 {{ "address.additionalField2Label"|trans|sw_sanitize }}{{ config('core.loginRegistration.additionalAddressField2Required') ? "general.required"|trans|sw_sanitize }}
  248.                             </label>
  249.                         {% endblock %}
  250.                         {% block component_address_form_additional_field2_input %}
  251.                             <input type="text"
  252.                                    class="form-control {% if violationPath %} is-invalid{% endif %}"
  253.                                    id="{{ idPrefix ~ prefix }}AdditionalField2"
  254.                                    placeholder="{{ "address.additionalField2Placeholder"|trans|striptags }}"
  255.                                    name="{{ prefix }}[additionalAddressLine2]"
  256.                                    value="{{ data.get('additionalAddressLine2') }}"
  257.                                     {{ config('core.loginRegistration.additionalAddressField2Required') ? 'required="true"' }}>
  258.                         {% endblock %}
  259.                         {% block component_address_form_additional_field2_error %}
  260.                             {% if violationPath %}
  261.                                 {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  262.                             {% endif %}
  263.                         {% endblock %}
  264.                     </div>
  265.                 {% endif %}
  266.             {% endblock %}
  267.         </div>
  268.         <div class="row g-2 country-and-state-form-elements" data-country-state-select="true">
  269.             {% block component_address_form_country %}
  270.                 <div class="form-group col-md-6">
  271.                     {% set initialCountryId = null %}
  272.                     {% if data.get('countryId') %}
  273.                         {% set initialCountryId = data.get('countryId') %}
  274.                     {% elseif page.countries|length == 1 %}
  275.                         {% set initialCountryId = (page.countries|first).id %}
  276.                     {% endif %}
  277.                     {% if formViolations.getViolations("/countryId") is not empty %}
  278.                         {% set violationPath = "/countryId" %}
  279.                     {% elseif formViolations.getViolations("/#{prefix}/countryId") is not empty %}
  280.                         {% set violationPath = "/#{prefix}/countryId" %}
  281.                     {% endif %}
  282.                     {% block component_address_form_country_label %}
  283.                         <label class="form-label"
  284.                                for="{{ idPrefix ~ prefix }}AddressCountry">
  285.                             {{ "address.countryLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  286.                         </label>
  287.                     {% endblock %}
  288.                     {% block component_address_form_country_select %}
  289.                         <select class="country-select form-select{% if violationPath %} is-invalid{% endif %}"
  290.                                 id="{{ idPrefix ~ prefix }}AddressCountry"
  291.                                 name="{{ prefix }}[countryId]"
  292.                                 required="required"
  293.                                 data-initial-country-id="{{ initialCountryId }}">
  294.                             {% if not initialCountryId %}
  295.                                 <option disabled="disabled"
  296.                                         value=""
  297.                                         selected="selected">
  298.                                     {{ "address.countryPlaceholder"|trans|sw_sanitize }}
  299.                                 </option>
  300.                             {% endif %}
  301.                             {% for country in page.countries %}
  302.                                 <option {% if country.id == initialCountryId %}
  303.                                         selected="selected"
  304.                                         {% endif %}
  305.                                         value="{{ country.id }}"
  306.                                         data-zipcode-required="{{ country.postalCodeRequired }}"
  307.                                         data-vat-id-required="{{ country.vatIdRequired }}"
  308.                                         data-state-required="{{ country.forceStateInRegistration }}"
  309.                                         {% if not country.shippingAvailable and disableNonShippableCountries %}
  310.                                             disabled="disabled"
  311.                                         {% endif %}>
  312.                                     {{ country.translated.name }}{% if showNoShippingPostfix and not country.shippingAvailable %} {{ "address.countryPostfixNoShipping"|trans|sw_sanitize }}{% endif %}
  313.                                 </option>
  314.                             {% endfor %}
  315.                         </select>
  316.                     {% endblock %}
  317.                 </div>
  318.                 <div class="form-group col-md-6  d-none">
  319.                     {% if formViolations.getViolations("/countryStateId") is not empty %}
  320.                         {% set violationPath = "/countryStateId" %}
  321.                     {% elseif formViolations.getViolations("/#{prefix}/countryStateId") is not empty %}
  322.                         {% set violationPath = "/#{prefix}/countryStateId" %}
  323.                     {% endif %}
  324.                     {% block component_address_form_country_state_label %}
  325.                         <label class="form-label"
  326.                                for="{{ idPrefix ~ prefix }}AddressCountryState">
  327.                             {{ "address.countryStateLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  328.                         </label>
  329.                     {% endblock %}
  330.                     {% block component_address_form_country_state_select %}
  331.                         <select class="country-state-select form-select{% if violationPath %} is-invalid{% endif %}"
  332.                                 id="{{ idPrefix ~ prefix }}AddressCountryState"
  333.                                 name="{{ prefix }}[countryStateId]"
  334.                                 data-initial-country-state-id="{{ data.get('countryStateId') }}">
  335.                             <option value=""
  336.                                     selected="selected"
  337.                                     data-placeholder-option="true">
  338.                                 {{ "address.countryStatePlaceholder"|trans|sw_sanitize }}
  339.                             </option>
  340.                         </select>
  341.                     {% endblock %}
  342.                     {% block component_address_form_country_error %}
  343.                         {% if violationPath %}
  344.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  345.                         {% endif %}
  346.                     {% endblock %}
  347.                 </div>
  348.             {% endblock %}
  349.         </div>
  350.         <div class="row g-2">
  351.             {% block component_address_form_phone_number %}
  352.                 {% if config('core.loginRegistration.showPhoneNumberField') %}
  353.                     <div class="form-group col-md-6">
  354.                         {% if formViolations.getViolations("/phoneNumber") is not empty %}
  355.                             {% set violationPath = "/phoneNumber" %}
  356.                         {% elseif formViolations.getViolations("/#{prefix}/phoneNumber") is not empty %}
  357.                             {% set violationPath = "/#{prefix}/phoneNumber" %}
  358.                         {% endif %}
  359.                         {% block component_address_form_phone_number_label %}
  360.                             <label class="form-label"
  361.                                    for="{{ idPrefix ~ prefix }}AddressPhoneNumber">
  362.                                 {{ "address.phoneNumberLabel"|trans|sw_sanitize }}{{ config('core.loginRegistration.phoneNumberFieldRequired') ? "general.required"|trans|sw_sanitize }}
  363.                             </label>
  364.                         {% endblock %}
  365.                         {% block component_address_form_phone_number_input %}
  366.                             <input type="text"
  367.                                    class="form-control"
  368.                                    id="{{ idPrefix ~ prefix }}AddressPhoneNumber"
  369.                                    placeholder="{{ "address.phoneNumberPlaceholder"|trans|striptags }}"
  370.                                    name="{{ prefix }}[phoneNumber]"
  371.                                    value="{{ data.get('phoneNumber') }}"
  372.                                 {{ config('core.loginRegistration.phoneNumberFieldRequired') ? 'required="true"' }}>
  373.                         {% endblock %}
  374.                         {% block component_address_form_phone_error %}
  375.                             {% if violationPath %}
  376.                                 {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  377.                             {% endif %}
  378.                         {% endblock %}
  379.                     </div>
  380.                 {% endif %}
  381.             {% endblock %}
  382.         </div>
  383.     {% endblock %}
  384. {% endblock %}