vendor/shopware/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.                 {# @deprecated tag:v6.6.0 - Will remove the if statement #}
  190.                 {% if config('core.address.showZipcodeInFrontOfCity') %}
  191.                     <div class="form-group col-md-2 col-4">
  192.                         {{ zipcodeField }}
  193.                     </div>
  194.                     <div class="form-group col-md-4 col-8">
  195.                         {{ cityField }}
  196.                     </div>
  197.                 {% else %}
  198.                     <div class="form-group col-md-4 col-8">
  199.                         {{ cityField }}
  200.                     </div>
  201.                     <div class="form-group col-md-2 col-4">
  202.                         {{ zipcodeField }}
  203.                     </div>
  204.                 {% endif %}
  205.             {% endblock %}
  206.             {% block component_address_form_additional_field1 %}
  207.                 {% if config('core.loginRegistration.showAdditionalAddressField1') %}
  208.                     {% if formViolations.getViolations("/additionalAddressLine1") is not empty %}
  209.                         {% set violationPath = "/additionalAddressLine1" %}
  210.                     {% elseif formViolations.getViolations("/#{prefix}/additionalAddressLine1") is not empty %}
  211.                         {% set violationPath = "/#{prefix}/additionalAddressLine1" %}
  212.                     {% endif %}
  213.                     <div class="form-group col-md-6">
  214.                         {% block component_address_form_additional_field1_label %}
  215.                             <label class="form-label"
  216.                                    for="{{ idPrefix ~ prefix }}AdditionalField1">
  217.                                 {{ "address.additionalField1Label"|trans|sw_sanitize }}{{ config('core.loginRegistration.additionalAddressField1Required') ? "general.required"|trans|sw_sanitize }}
  218.                             </label>
  219.                         {% endblock %}
  220.                         {% block component_address_form_additional_field1_input %}
  221.                             <input type="text"
  222.                                    class="form-control {% if violationPath %} is-invalid{% endif %}"
  223.                                    id="{{ idPrefix ~ prefix }}AdditionalField1"
  224.                                    placeholder="{{ "address.additionalField1Placeholder"|trans|striptags }}"
  225.                                    name="{{ prefix }}[additionalAddressLine1]"
  226.                                    value="{{ data.get('additionalAddressLine1') }}"
  227.                                     {{ config('core.loginRegistration.additionalAddressField1Required') ? 'required="true"' }}>
  228.                         {% endblock %}
  229.                         {% block component_address_form_additional_field1_error %}
  230.                             {% if violationPath %}
  231.                                 {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  232.                             {% endif %}
  233.                         {% endblock %}
  234.                     </div>
  235.                 {% endif %}
  236.             {% endblock %}
  237.             {% block component_address_form_additional_field2 %}
  238.                 {% if config('core.loginRegistration.showAdditionalAddressField2') %}
  239.                     {% if formViolations.getViolations("/additionalAddressLine2") is not empty %}
  240.                         {% set violationPath = "/additionalAddressLine2" %}
  241.                     {% elseif formViolations.getViolations("/#{prefix}/additionalAddressLine2") is not empty %}
  242.                         {% set violationPath = "/#{prefix}/additionalAddressLine2" %}
  243.                     {% endif %}
  244.                     <div class="form-group col-md-6">
  245.                         {% block component_address_form_additional_field2_label %}
  246.                             <label class="form-label"
  247.                                    for="{{ idPrefix ~ prefix }}AdditionalField2">
  248.                                 {{ "address.additionalField2Label"|trans|sw_sanitize }}{{ config('core.loginRegistration.additionalAddressField2Required') ? "general.required"|trans|sw_sanitize }}
  249.                             </label>
  250.                         {% endblock %}
  251.                         {% block component_address_form_additional_field2_input %}
  252.                             <input type="text"
  253.                                    class="form-control {% if violationPath %} is-invalid{% endif %}"
  254.                                    id="{{ idPrefix ~ prefix }}AdditionalField2"
  255.                                    placeholder="{{ "address.additionalField2Placeholder"|trans|striptags }}"
  256.                                    name="{{ prefix }}[additionalAddressLine2]"
  257.                                    value="{{ data.get('additionalAddressLine2') }}"
  258.                                     {{ config('core.loginRegistration.additionalAddressField2Required') ? 'required="true"' }}>
  259.                         {% endblock %}
  260.                         {% block component_address_form_additional_field2_error %}
  261.                             {% if violationPath %}
  262.                                 {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  263.                             {% endif %}
  264.                         {% endblock %}
  265.                     </div>
  266.                 {% endif %}
  267.             {% endblock %}
  268.         </div>
  269.         <div class="row g-2 country-and-state-form-elements" data-country-state-select="true">
  270.             {% block component_address_form_country %}
  271.                 <div class="form-group col-md-6">
  272.                     {% set initialCountryId = null %}
  273.                     {% if data.get('countryId') %}
  274.                         {% set initialCountryId = data.get('countryId') %}
  275.                     {% elseif page.countries|length == 1 and disableNonShippableCountries is not defined %}
  276.                         {% set initialCountryId = (page.countries|first).id %}
  277.                     {% endif %}
  278.                     {% if formViolations.getViolations("/countryId") is not empty %}
  279.                         {% set violationPath = "/countryId" %}
  280.                     {% elseif formViolations.getViolations("/#{prefix}/countryId") is not empty %}
  281.                         {% set violationPath = "/#{prefix}/countryId" %}
  282.                     {% endif %}
  283.                     {% block component_address_form_country_label %}
  284.                         <label class="form-label"
  285.                                for="{{ idPrefix ~ prefix }}AddressCountry">
  286.                             {{ "address.countryLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  287.                         </label>
  288.                     {% endblock %}
  289.                     {% block component_address_form_country_select %}
  290.                         <select class="country-select form-select{% if violationPath %} is-invalid{% endif %}"
  291.                                 id="{{ idPrefix ~ prefix }}AddressCountry"
  292.                                 name="{{ prefix }}[countryId]"
  293.                                 required="required"
  294.                                 data-initial-country-id="{{ initialCountryId }}">
  295.                             {% if not initialCountryId %}
  296.                                 <option disabled="disabled"
  297.                                         value=""
  298.                                         selected="selected">
  299.                                     {{ "address.countryPlaceholder"|trans|sw_sanitize }}
  300.                                 </option>
  301.                             {% endif %}
  302.                             {% for country in page.countries %}
  303.                                 <option {% if country.id == initialCountryId %}
  304.                                         selected="selected"
  305.                                         {% endif %}
  306.                                         value="{{ country.id }}"
  307.                                         data-zipcode-required="{{ country.postalCodeRequired }}"
  308.                                         data-vat-id-required="{{ country.vatIdRequired }}"
  309.                                         data-state-required="{{ country.forceStateInRegistration }}"
  310.                                         {% if not country.shippingAvailable and disableNonShippableCountries %}
  311.                                             disabled="disabled"
  312.                                         {% endif %}>
  313.                                     {{ country.translated.name }}{% if showNoShippingPostfix and not country.shippingAvailable %} {{ "address.countryPostfixNoShipping"|trans|sw_sanitize }}{% endif %}
  314.                                 </option>
  315.                             {% endfor %}
  316.                         </select>
  317.                     {% endblock %}
  318.                 </div>
  319.                 <div class="form-group col-md-6 d-none">
  320.                     {% if formViolations.getViolations("/countryStateId") is not empty %}
  321.                         {% set violationPath = "/countryStateId" %}
  322.                     {% elseif formViolations.getViolations("/#{prefix}/countryStateId") is not empty %}
  323.                         {% set violationPath = "/#{prefix}/countryStateId" %}
  324.                     {% endif %}
  325.                     {% block component_address_form_country_state_label %}
  326.                         <label class="form-label"
  327.                                for="{{ idPrefix ~ prefix }}AddressCountryState">
  328.                             {{ "address.countryStateLabel"|trans|sw_sanitize }}
  329.                         </label>
  330.                     {% endblock %}
  331.                     {% block component_address_form_country_state_select %}
  332.                         <select class="country-state-select form-select{% if violationPath %} is-invalid{% endif %}"
  333.                                 id="{{ idPrefix ~ prefix }}AddressCountryState"
  334.                                 name="{{ prefix }}[countryStateId]"
  335.                                 data-initial-country-state-id="{{ data.get('countryStateId') }}">
  336.                             <option value=""
  337.                                     selected="selected"
  338.                                     data-placeholder-option="true">
  339.                                 {{ "address.countryStatePlaceholder"|trans|sw_sanitize }}
  340.                             </option>
  341.                         </select>
  342.                     {% endblock %}
  343.                     {% block component_address_form_country_error %}
  344.                         {% if violationPath %}
  345.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  346.                         {% endif %}
  347.                     {% endblock %}
  348.                 </div>
  349.             {% endblock %}
  350.         </div>
  351.         <div class="row g-2">
  352.             {% block component_address_form_phone_number %}
  353.                 {% if config('core.loginRegistration.showPhoneNumberField') %}
  354.                     <div class="form-group col-md-6">
  355.                         {% if formViolations.getViolations("/phoneNumber") is not empty %}
  356.                             {% set violationPath = "/phoneNumber" %}
  357.                         {% elseif formViolations.getViolations("/#{prefix}/phoneNumber") is not empty %}
  358.                             {% set violationPath = "/#{prefix}/phoneNumber" %}
  359.                         {% endif %}
  360.                         {% block component_address_form_phone_number_label %}
  361.                             <label class="form-label"
  362.                                    for="{{ idPrefix ~ prefix }}AddressPhoneNumber">
  363.                                 {{ "address.phoneNumberLabel"|trans|sw_sanitize }}{{ config('core.loginRegistration.phoneNumberFieldRequired') ? "general.required"|trans|sw_sanitize }}
  364.                             </label>
  365.                         {% endblock %}
  366.                         {% block component_address_form_phone_number_input %}
  367.                             <input type="text"
  368.                                    class="form-control"
  369.                                    id="{{ idPrefix ~ prefix }}AddressPhoneNumber"
  370.                                    placeholder="{{ "address.phoneNumberPlaceholder"|trans|striptags }}"
  371.                                    name="{{ prefix }}[phoneNumber]"
  372.                                    value="{{ data.get('phoneNumber') }}"
  373.                                 {{ config('core.loginRegistration.phoneNumberFieldRequired') ? 'required="true"' }}>
  374.                         {% endblock %}
  375.                         {% block component_address_form_phone_error %}
  376.                             {% if violationPath %}
  377.                                 {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' %}
  378.                             {% endif %}
  379.                         {% endblock %}
  380.                     </div>
  381.                 {% endif %}
  382.             {% endblock %}
  383.         </div>
  384.     {% endblock %}
  385. {% endblock %}