{% block component_address_field_country %} {% if initialCountryId is not defined %} {% set initialCountryId = context.salesChannel.countryId %} {% endif %} {% if data.get('countryId') %} {% set initialCountryId = data.get('countryId') %} {% elseif page.countries|length == 1 and disableNonShippableCountries is not defined %} {% set initialCountryId = (page.countries|first).id %} {% endif %} {% if formViolations.getViolations('/countryId') is not empty %} {% set violationPath = '/countryId' %} {% elseif formViolations.getViolations("/#{prefix}/countryId") is not empty %} {% set violationPath = "/#{prefix}/countryId" %} {% endif %} {% set countryAutocomplete = 'country-name' %} {% if prefix == 'shippingAddress' %} {% set countryAutocomplete = 'shipping country-name' %} {% elseif prefix == 'billingAddress' %} {% set countryAutocomplete = 'billing country-name' %} {% endif %} {% set countryOptions %} {% if not initialCountryId %} {% endif %} {% for country in page.countries %} {% endfor %} {% endset %} {% sw_include '@Storefront/storefront/component/form/form-select.html.twig' with { label: 'address.countryLabel'|trans|sw_sanitize, id: idPrefix ~ prefix ~ 'AddressCountry', name: prefix ~ '[countryId]', autocomplete: countryAutocomplete, options: countryOptions, violationPath: violationPath, validationRules: 'required', additionalClass: additionalClass ?? 'col-md-6', additionalSelectClass: 'country-select', attributes: { 'data-initial-country-id': initialCountryId, } } %} {% endblock %}