vendor/shopware/storefront/Resources/views/storefront/component/address/address-personal.html.twig line 1

Open in your IDE?
  1. {# Provides customer type, salutation, title, firstname, lastname and birthday fields for address forms (e.g. registering a user, creating or updating an address) #}
  2. {% block component_address_personal_fields %}
  3.     {% block component_address_personal_account_type %}
  4.         {% if shopware.config.core.loginRegistration.showAccountTypeSelection and not hideCustomerTypeSelect %}
  5.             <div class="form-row">
  6.                 <div class="form-group col-md-3 col-sm-6 contact-type">
  7.                     {% block component_address_personal_account_type_label %}
  8.                         <label class="form-label"
  9.                                for="{{ prefix }}accountType">
  10.                             {{ "account.personalTypeLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  11.                         </label>
  12.                     {% endblock %}
  13.                     {% block component_address_personal_account_type_select %}
  14.                         <select name="{% if prefix %}{{ prefix }}[accountType]{% else %}accountType{% endif %}"
  15.                                 id="{{ prefix }}accountType"
  16.                                 required="required"
  17.                                 class="custom-select contact-select{% if formViolations.getViolations('/typeId') %} is-invalid{% endif %}"
  18.                                 data-form-field-toggle="true"
  19.                                 data-form-field-toggle-target=".js-field-toggle-contact-type-company"
  20.                                 data-form-field-toggle-value="{{ constant('Shopware\\Core\\Checkout\\Customer\\CustomerEntity::ACCOUNT_TYPE_BUSINESS') }}">
  21.                             {% if page.address.company %}
  22.                                 <option value="{{ constant('Shopware\\Core\\Checkout\\Customer\\CustomerEntity::ACCOUNT_TYPE_PRIVATE') }}">
  23.                                     {{ "account.personalTypePrivate"|trans|sw_sanitize }}
  24.                                 </option>
  25.                                 <option value="{{ constant('Shopware\\Core\\Checkout\\Customer\\CustomerEntity::ACCOUNT_TYPE_BUSINESS') }}"
  26.                                         selected="selected">
  27.                                     {{ "account.personalTypeBusiness"|trans|sw_sanitize }}
  28.                                 </option>
  29.                             {% elseif prefix == "address" and not page.address.company %}
  30.                                 <option value="{{ constant('Shopware\\Core\\Checkout\\Customer\\CustomerEntity::ACCOUNT_TYPE_PRIVATE') }}"
  31.                                         selected="selected">
  32.                                     {{ "account.personalTypePrivate"|trans|sw_sanitize }}
  33.                                 </option>
  34.                                 <option value="{{ constant('Shopware\\Core\\Checkout\\Customer\\CustomerEntity::ACCOUNT_TYPE_BUSINESS') }}">
  35.                                     {{ "account.personalTypeBusiness"|trans|sw_sanitize }}
  36.                                 </option>
  37.                             {% else %}
  38.                                 <option disabled="disabled"
  39.                                         selected="selected"
  40.                                         value="">
  41.                                     {{ "account.personalTypeLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  42.                                 </option>
  43.                                 <option value="{{ constant('Shopware\\Core\\Checkout\\Customer\\CustomerEntity::ACCOUNT_TYPE_PRIVATE') }}">
  44.                                     {{ "account.personalTypePrivate"|trans|sw_sanitize }}
  45.                                 </option>
  46.                                 <option value="{{ constant('Shopware\\Core\\Checkout\\Customer\\CustomerEntity::ACCOUNT_TYPE_BUSINESS') }}">
  47.                                     {{ "account.personalTypeBusiness"|trans|sw_sanitize }}
  48.                                 </option>
  49.                             {% endif %}
  50.                         </select>
  51.                     {% endblock %}
  52.                     {% block component_address_personal_account_type_error %}
  53.                         {% if formViolations.getViolations('/company') is not empty %}
  54.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' with {
  55.                                 violationPath: '/company'
  56.                             } %}
  57.                         {% endif %}
  58.                     {% endblock %}
  59.                 </div>
  60.             </div>
  61.         {% else %}
  62.             <input type="hidden" name="accountType">
  63.         {% endif %}
  64.     {% endblock %}
  65.     {% block component_address_personal_fields_salutation_title %}
  66.         <div class="form-row">
  67.             {% block component_address_personal_fields_salutation %}
  68.                 <div class="form-group col-md-3 col-sm-6">
  69.                     {% block component_address_personal_fields_salutation_label %}
  70.                         <label class="form-label"
  71.                                for="{{ prefix }}personalSalutation">
  72.                             {{ "account.personalSalutationLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  73.                         </label>
  74.                     {% endblock %}
  75.                     {% block component_address_form_salutation_select %}
  76.                         <select id="{{ prefix }}personalSalutation"
  77.                                 class="custom-select{% if formViolations.getViolations('/salutationId') is not empty %} is-invalid{% endif %}"
  78.                                 name="{% if prefix %}{{ prefix }}[salutationId]{% else %}salutationId{% endif %}"
  79.                                 required="required">
  80.                             {% if not data.get('salutationId') %}
  81.                                 <option disabled="disabled"
  82.                                         selected="selected"
  83.                                         value="">
  84.                                     {{ "account.personalSalutationPlaceholder"|trans|sw_sanitize }}
  85.                                 </option>
  86.                             {% endif %}
  87.                             {% for salutation in page.salutations %}
  88.                                 <option {% if salutation.id == data.get('salutationId') %}
  89.                                     selected="selected"
  90.                                 {% endif %}
  91.                                         value="{{ salutation.id }}">
  92.                                     {{ salutation.translated.displayName }}
  93.                                 </option>
  94.                             {% endfor %}
  95.                         </select>
  96.                     {% endblock %}
  97.                     {% block component_address_form_salutation_select_error %}
  98.                         {% if formViolations.getViolations('/salutationId') is not empty %}
  99.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' with {
  100.                                 violationPath: '/salutationId'
  101.                             } %}
  102.                         {% endif %}
  103.                     {% endblock %}
  104.                 </div>
  105.             {% endblock %}
  106.             {% block component_address_personal_fields_title %}
  107.                 {% if shopware.config.core.loginRegistration.showTitleField %}
  108.                     <div class="form-group col-md-3 col-sm-6">
  109.                         {% block component_address_personal_fields_title_label %}
  110.                             <label class="form-label"
  111.                                    for="{{ prefix }}personalTitle">
  112.                                 {{ "account.personalTitleLabel"|trans|sw_sanitize }}
  113.                             </label>
  114.                         {% endblock %}
  115.                         {% block component_address_personal_fields_title_input %}
  116.                             <input type="text"
  117.                                    class="form-control"
  118.                                    autocomplete="section-personal title"
  119.                                    id="{{ prefix }}personalTitle"
  120.                                    placeholder="{{ "account.personalTitlePlaceholder"|trans|striptags }}"
  121.                                    name="{% if prefix %}{{ prefix }}[title]{% else %}title{% endif %}"
  122.                                    value="{{ data.get('title') }}">
  123.                         {% endblock %}
  124.                     </div>
  125.                 {% endif %}
  126.             {% endblock %}
  127.         </div>
  128.     {% endblock %}
  129.     {% block component_address_personal_fields_name %}
  130.         <div class="form-row">
  131.             {% block component_address_personal_fields_first_name %}
  132.                 <div class="form-group col-sm-6">
  133.                     {% block component_address_personal_fields_first_name_label %}
  134.                         <label class="form-label"
  135.                                for="{{ prefix }}personalFirstName">
  136.                             {{ "account.personalFirstNameLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  137.                         </label>
  138.                     {% endblock %}
  139.                     {% block component_address_personal_fields_first_name_input %}
  140.                         <input type="text"
  141.                                class="form-control{% if formViolations.getViolations('/firstName') is not empty %} is-invalid{% endif %}"
  142.                                autocomplete="section-personal given-name"
  143.                                id="{{ prefix }}personalFirstName"
  144.                                placeholder="{{ "account.personalFirstNamePlaceholder"|trans|striptags }}"
  145.                                name="{% if prefix %}{{ prefix }}[firstName]{% else %}firstName{% endif %}"
  146.                                value="{{ data.get('firstName') }}"
  147.                                required="required">
  148.                     {% endblock %}
  149.                     {% block component_address_personal_fields_first_name_input_error %}
  150.                         {% if formViolations.getViolations('/firstName') is not empty %}
  151.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' with {
  152.                                 violationPath: '/firstName'
  153.                             } %}
  154.                         {% endif %}
  155.                     {% endblock %}
  156.                 </div>
  157.             {% endblock %}
  158.             {% block component_address_personal_fields_last_name %}
  159.                 <div class="form-group col-sm-6">
  160.                     {% block component_address_personal_fields_last_name_label %}
  161.                         <label class="form-label"
  162.                                for="{{ prefix }}personalLastName">
  163.                             {{ "account.personalLastNameLabel"|trans|sw_sanitize }}{{ "general.required"|trans|sw_sanitize }}
  164.                         </label>
  165.                     {% endblock %}
  166.                     {% block component_address_personal_fields_last_name_input %}
  167.                         <input type="text"
  168.                                class="form-control{% if formViolations.getViolations('/lastName') is not empty %} is-invalid{% endif %}"
  169.                                autocomplete="section-personal family-name"
  170.                                id="{{ prefix }}personalLastName"
  171.                                placeholder="{{ "account.personalLastNamePlaceholder"|trans|striptags }}"
  172.                                name="{% if prefix %}{{ prefix }}[lastName]{% else %}lastName{% endif %}"
  173.                                value="{{ data.get('lastName') }}"
  174.                                required="required">
  175.                     {% endblock %}
  176.                     {% block component_address_personal_fields_last_name_input_error %}
  177.                         {% if formViolations.getViolations('/lastName') is not empty %}
  178.                             {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' with {
  179.                                 violationPath: '/lastName'
  180.                             } %}
  181.                         {% endif %}
  182.                     {% endblock %}
  183.                 </div>
  184.             {% endblock %}
  185.         </div>
  186.     {% endblock %}
  187.     {% block component_address_personal_fields_birthday %}
  188.         {% if showBirthdayField %}
  189.             {% block component_address_personal_fields_birthday_label %}
  190.                 <label for="{{ prefix }}personalBirthday">
  191.                     {{ "account.personalBirthdayLabel"|trans|sw_sanitize }}{{ shopware.config.core.loginRegistration.birthdayFieldRequired ? "general.required"|trans|sw_sanitize }}
  192.                 </label>
  193.             {% endblock %}
  194.             {% block component_address_personal_fields_birthday_selects %}
  195.                 <div class="form-row">
  196.                     {% block component_address_personal_fields_birthday_select_day %}
  197.                         <div class="form-group col-md-2 col-4">
  198.                             <select id="{{ prefix }}personalBirthday"
  199.                                     name="{% if prefix %}{{ prefix }}[birthdayDay]{% else %}birthdayDay{% endif %}"
  200.                                     class="custom-select{% if formViolations.getViolations('/birthdayDay') is not empty %} is-invalid{% endif %}"
  201.                                     {{ shopware.config.core.loginRegistration.birthdayFieldRequired ? 'required="required"' }}>
  202.                                 {% if not data.get('birthdayDay') %}
  203.                                     <option selected="selected"
  204.                                             value="">
  205.                                         {{ "account.personalBirthdaySelectDay"|trans|sw_sanitize }}
  206.                                     </option>
  207.                                 {% endif %}
  208.                                 {% for day in range(1, 31) %}
  209.                                     <option value="{{ day }}"
  210.                                             {% if day == data.get('birthdayDay') %} selected="selected"{% endif %}>
  211.                                         {{ day }}
  212.                                     </option>
  213.                                 {% endfor %}
  214.                             </select>
  215.                             {% block component_address_personal_fields_birthday_select_day_error %}
  216.                                 {% if formViolations.getViolations('/birthdayDay') is not empty %}
  217.                                     {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' with {
  218.                                         violationPath: '/birthdayDay'
  219.                                     } %}
  220.                                 {% endif %}
  221.                             {% endblock %}
  222.                         </div>
  223.                     {% endblock %}
  224.                     {% block component_address_personal_fields_birthday_select_month %}
  225.                         <div class="form-group col-md-2 col-4">
  226.                             <select name="{% if prefix %}{{ prefix }}[birthdayMonth]{% else %}birthdayMonth{% endif %}"
  227.                                     class="custom-select{% if formViolations.getViolations('/birthdayMonth') is not empty %} is-invalid{% endif %}"
  228.                                     {{ shopware.config.core.loginRegistration.birthdayFieldRequired ? 'required="required"' }}>
  229.                                 {% if not data.get('birthdayMonth') %}
  230.                                     <option selected="selected"
  231.                                             value="">
  232.                                         {{ "account.personalBirthdaySelectMonth"|trans|sw_sanitize }}
  233.                                     </option>
  234.                                 {% endif %}
  235.                                 {% for month in range(1, 12) %}
  236.                                     <option value="{{ month }}"
  237.                                             {% if month == data.get('birthdayMonth') %} selected="selected"{% endif %}>
  238.                                         {{ month }}
  239.                                     </option>
  240.                                 {% endfor %}
  241.                             </select>
  242.                             {% block component_address_personal_fields_birthday_select_month_error %}
  243.                                 {% if formViolations.getViolations('/birthdayMonth') is not empty %}
  244.                                     {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' with {
  245.                                         violationPath: '/birthdayMonth'
  246.                                     } %}
  247.                                 {% endif %}
  248.                             {% endblock %}
  249.                         </div>
  250.                     {% endblock %}
  251.                     {% block component_address_personal_fields_birthday_select_year %}
  252.                         <div class="form-group col-md-2 col-4">
  253.                             {% set currentYear = "now"|date('Y') %}
  254.                             {% set startYear = currentYear - 120 %}
  255.                             <select name="{% if prefix %}{{ prefix }}[birthdayYear]{% else %}birthdayYear{% endif %}"
  256.                                     class="custom-select{% if formViolations.getViolations('/birthdayYear') is not empty %} is-invalid{% endif %}"
  257.                                     {{ shopware.config.core.loginRegistration.birthdayFieldRequired ? 'required="required"' }}>
  258.                                 {% if not data.get('birthdayYear') %}
  259.                                     <option selected="selected"
  260.                                             value="">
  261.                                         {{ "account.personalBirthdaySelectYear"|trans|sw_sanitize }}
  262.                                     </option>
  263.                                 {% endif %}
  264.                                 {% for year in range(currentYear, startYear) %}
  265.                                     <option value="{{ year }}"
  266.                                             {% if year == data.get('birthdayYear') %} selected="selected"{% endif %}>
  267.                                         {{ year }}
  268.                                     </option>
  269.                                 {% endfor %}
  270.                             </select>
  271.                             {% block component_address_personal_fields_birthday_select_year_error %}
  272.                                 {% if formViolations.getViolations('/birthdayYear') is not empty %}
  273.                                     {% sw_include '@Storefront/storefront/utilities/form-violation.html.twig' with {
  274.                                         violationPath: '/birthdayYear'
  275.                                     } %}
  276.                                 {% endif %}
  277.                             {% endblock %}
  278.                         </div>
  279.                     {% endblock %}
  280.                 </div>
  281.             {% endblock %}
  282.         {% endif %}
  283.     {% endblock %}
  284. {% endblock %}