register.phtml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. // @codingStandardsIgnoreFile
  7. /** @var \Magento\Customer\Block\Form\Register $block */
  8. ?>
  9. <?= $block->getChildHtml('form_fields_before') ?>
  10. <?php /* Extensions placeholder */ ?>
  11. <?= $block->getChildHtml('customer.form.register.extra') ?>
  12. <form class="form create account form-create-account" action="<?= $block->escapeUrl($block->getPostActionUrl()) ?>" method="post" id="form-validate" enctype="multipart/form-data" autocomplete="off">
  13. <?= /* @noEscape */ $block->getBlockHtml('formkey'); ?>
  14. <fieldset class="fieldset create info">
  15. <legend class="legend"><span><?= $block->escapeHtml(__('Personal Information')) ?></span></legend><br>
  16. <input type="hidden" name="success_url" value="<?= $block->escapeUrl($block->getSuccessUrl()) ?>">
  17. <input type="hidden" name="error_url" value="<?= $block->escapeUrl($block->getErrorUrl()) ?>">
  18. <?= $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Name')->setObject($block->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
  19. <?php if ($block->isNewsletterEnabled()): ?>
  20. <div class="field choice newsletter">
  21. <input type="checkbox" name="is_subscribed" title="<?= $block->escapeHtmlAttr(__('Sign Up for Newsletter')) ?>" value="1" id="is_subscribed"<?php if ($block->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox">
  22. <label for="is_subscribed" class="label"><span><?= $block->escapeHtml(__('Sign Up for Newsletter')) ?></span></label>
  23. </div>
  24. <?php /* Extensions placeholder */ ?>
  25. <?= $block->getChildHtml('customer.form.register.newsletter') ?>
  26. <?php endif ?>
  27. <?php $_dob = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Dob') ?>
  28. <?php if ($_dob->isEnabled()): ?>
  29. <?= $_dob->setDate($block->getFormData()->getDob())->toHtml() ?>
  30. <?php endif ?>
  31. <?php $_taxvat = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Taxvat') ?>
  32. <?php if ($_taxvat->isEnabled()): ?>
  33. <?= $_taxvat->setTaxvat($block->getFormData()->getTaxvat())->toHtml() ?>
  34. <?php endif ?>
  35. <?php $_gender = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Gender') ?>
  36. <?php if ($_gender->isEnabled()): ?>
  37. <?= $_gender->setGender($block->getFormData()->getGender())->toHtml() ?>
  38. <?php endif ?>
  39. </fieldset>
  40. <?php if ($block->getShowAddressFields()): ?>
  41. <fieldset class="fieldset address">
  42. <legend class="legend"><span><?= $block->escapeHtml(__('Address Information')) ?></span></legend><br>
  43. <input type="hidden" name="create_address" value="1" />
  44. <?php $_company = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Company') ?>
  45. <?php if ($_company->isEnabled()): ?>
  46. <?= $_company->setCompany($block->getFormData()->getCompany())->toHtml() ?>
  47. <?php endif ?>
  48. <?php $_telephone = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Telephone') ?>
  49. <?php if ($_telephone->isEnabled()): ?>
  50. <?= $_telephone->setTelephone($block->getFormData()->getTelephone())->toHtml() ?>
  51. <?php endif ?>
  52. <?php $_fax = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Fax') ?>
  53. <?php if ($_fax->isEnabled()): ?>
  54. <?= $_fax->setFax($block->getFormData()->getFax())->toHtml() ?>
  55. <?php endif ?>
  56. <?php $_streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?>
  57. <div class="field street required">
  58. <label for="street_1" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?></span></label>
  59. <div class="control">
  60. <input type="text" name="street[]" value="<?= $block->escapeHtmlAttr($block->getFormData()->getStreet(0)) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?>" id="street_1" class="input-text <?= $block->escapeHtmlAttr($_streetValidationClass) ?>">
  61. <div class="nested">
  62. <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
  63. <?php for ($_i = 2, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?>
  64. <div class="field additional">
  65. <label class="label" for="street_<?= /* @noEscape */ $_i ?>">
  66. <span><?= $block->escapeHtml(__('Address')) ?></span>
  67. </label>
  68. <div class="control">
  69. <input type="text" name="street[]" value="<?= $block->escapeHtml($block->getFormData()->getStreetLine($_i - 1)) ?>" title="<?= $block->escapeHtmlAttr(__('Street Address %1', $_i)) ?>" id="street_<?= /* @noEscape */ $_i ?>" class="input-text <?= $block->escapeHtmlAttr($_streetValidationClass) ?>">
  70. </div>
  71. </div>
  72. <?php endfor; ?>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="field required">
  77. <label for="city" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('city') ?></span></label>
  78. <div class="control">
  79. <input type="text" name="city" value="<?= $block->escapeHtmlAttr($block->getFormData()->getCity()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('city') ?>" class="input-text <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('city')) ?>" id="city">
  80. </div>
  81. </div>
  82. <div class="field region required">
  83. <label for="region_id" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?></span></label>
  84. <div class="control">
  85. <select id="region_id" name="region_id" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>" class="validate-select region_id" style="display:none;">
  86. <option value=""><?= $block->escapeHtml(__('Please select a region, state or province.')) ?></option>
  87. </select>
  88. <input type="text" id="region" name="region" value="<?= $block->escapeHtml($block->getRegion()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>" class="input-text <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region')) ?>" style="display:none;">
  89. </div>
  90. </div>
  91. <div class="field zip required">
  92. <label for="zip" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?></span></label>
  93. <div class="control">
  94. <input type="text" name="postcode" value="<?= $block->escapeHtmlAttr($block->getFormData()->getPostcode()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?>" id="zip" class="input-text validate-zip-international <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('postcode')) ?>">
  95. </div>
  96. </div>
  97. <div class="field country required">
  98. <label for="country" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('country_id') ?></span></label>
  99. <div class="control">
  100. <?= $block->getCountryHtmlSelect() ?>
  101. </div>
  102. </div>
  103. <?php $addressAttributes = $block->getChildBlock('customer_form_address_user_attributes');?>
  104. <?php if ($addressAttributes): ?>
  105. <?php $addressAttributes->setEntityType('customer_address'); ?>
  106. <?php $addressAttributes->setFieldIdFormat('address:%1$s')->setFieldNameFormat('address[%1$s]');?>
  107. <?php $block->restoreSessionData($addressAttributes->getMetadataForm(), 'address');?>
  108. <?= $addressAttributes->setShowContainer(false)->toHtml() ?>
  109. <?php endif;?>
  110. <input type="hidden" name="default_billing" value="1">
  111. <input type="hidden" name="default_shipping" value="1">
  112. </fieldset>
  113. <?php endif; ?>
  114. <fieldset class="fieldset create account" data-hasrequired="<?= $block->escapeHtmlAttr(__('* Required Fields')) ?>">
  115. <legend class="legend"><span><?= $block->escapeHtml(__('Sign-in Information')) ?></span></legend><br>
  116. <div class="field required">
  117. <label for="email_address" class="label"><span><?= $block->escapeHtml(__('Email')) ?></span></label>
  118. <div class="control">
  119. <input type="email" name="email" autocomplete="email" id="email_address" value="<?= $block->escapeHtmlAttr($block->getFormData()->getEmail()) ?>" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" class="input-text" data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-email':true}">
  120. </div>
  121. </div>
  122. <div class="field password required">
  123. <label for="password" class="label"><span><?= $block->escapeHtml(__('Password')) ?></span></label>
  124. <div class="control">
  125. <input type="password" name="password" id="password"
  126. title="<?= $block->escapeHtmlAttr(__('Password')) ?>"
  127. class="input-text"
  128. data-password-min-length="<?= $block->escapeHtmlAttr($block->getMinimumPasswordLength()) ?>"
  129. data-password-min-character-sets="<?= $block->escapeHtmlAttr($block->getRequiredCharacterClassesNumber()) ?>"
  130. data-validate="{required:true, 'validate-customer-password':true}"
  131. autocomplete="off">
  132. <div id="password-strength-meter-container" data-role="password-strength-meter" aria-live="polite">
  133. <div id="password-strength-meter" class="password-strength-meter">
  134. <?= $block->escapeHtml(__('Password Strength')) ?>:
  135. <span id="password-strength-meter-label" data-role="password-strength-meter-label">
  136. <?= $block->escapeHtml(__('No Password')) ?>
  137. </span>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. <div class="field confirmation required">
  143. <label for="password-confirmation" class="label"><span><?= $block->escapeHtml(__('Confirm Password')) ?></span></label>
  144. <div class="control">
  145. <input type="password" name="password_confirmation" title="<?= $block->escapeHtmlAttr(__('Confirm Password')) ?>" id="password-confirmation" class="input-text" data-validate="{required:true, equalTo:'#password'}" autocomplete="off">
  146. </div>
  147. </div>
  148. <?= $block->getChildHtml('form_additional_info') ?>
  149. </fieldset>
  150. <div class="actions-toolbar">
  151. <div class="primary">
  152. <button type="submit" class="action submit primary" title="<?= $block->escapeHtmlAttr(__('Create an Account')) ?>"><span><?= $block->escapeHtml(__('Create an Account')) ?></span></button>
  153. </div>
  154. <div class="secondary">
  155. <a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>"><span><?= $block->escapeHtml(__('Back')) ?></span></a>
  156. </div>
  157. </div>
  158. </form>
  159. <script>
  160. require([
  161. 'jquery',
  162. 'mage/mage'
  163. ], function($){
  164. var dataForm = $('#form-validate');
  165. var ignore = <?= /* @noEscape */ $_dob->isEnabled() ? '\'input[id$="full"]\'' : 'null' ?>;
  166. dataForm.mage('validation', {
  167. <?php if ($_dob->isEnabled()): ?>
  168. errorPlacement: function(error, element) {
  169. if (element.prop('id').search('full') !== -1) {
  170. var dobElement = $(element).parents('.customer-dob'),
  171. errorClass = error.prop('class');
  172. error.insertAfter(element.parent());
  173. dobElement.find('.validate-custom').addClass(errorClass)
  174. .after('<div class="' + errorClass + '"></div>');
  175. }
  176. else {
  177. error.insertAfter(element);
  178. }
  179. },
  180. ignore: ':hidden:not(' + ignore + ')'
  181. <?php else: ?>
  182. ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
  183. <?php endif ?>
  184. }).find('input:text').attr('autocomplete', 'off');
  185. });
  186. </script>
  187. <?php if ($block->getShowAddressFields()): ?>
  188. <script type="text/x-magento-init">
  189. {
  190. "#country": {
  191. "regionUpdater": {
  192. "optionalRegionAllowed": <?= /* @noEscape */ $block->getConfig('general/region/display_all') ? 'true' : 'false' ?>,
  193. "regionListId": "#region_id",
  194. "regionInputId": "#region",
  195. "postcodeId": "#zip",
  196. "form": "#form-validate",
  197. "regionJson": <?= /* @noEscape */ $this->helper(\Magento\Directory\Helper\Data::class)->getRegionJson() ?>,
  198. "defaultRegion": "<?= (int) $block->getFormData()->getRegionId() ?>",
  199. "countriesWithOptionalZip": <?= /* @noEscape */ $this->helper(\Magento\Directory\Helper\Data::class)->getCountriesWithOptionalZip(true) ?>
  200. }
  201. }
  202. }
  203. </script>
  204. <?php endif; ?>
  205. <script type="text/x-magento-init">
  206. {
  207. ".field.password": {
  208. "passwordStrengthIndicator": {
  209. "formSelector": "form.form-create-account"
  210. }
  211. }
  212. }
  213. </script>