edit.phtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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\Address\Edit $block */
  8. ?>
  9. <?php $_company = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Company') ?>
  10. <?php $_telephone = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Telephone') ?>
  11. <?php $_fax = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Fax') ?>
  12. <form class="form-address-edit"
  13. action="<?= $block->escapeUrl($block->getSaveUrl()) ?>"
  14. method="post"
  15. id="form-validate"
  16. enctype="multipart/form-data"
  17. data-hasrequired="<?= $block->escapeHtmlAttr(__('* Required Fields')) ?>">
  18. <fieldset class="fieldset">
  19. <legend class="legend"><span><?= $block->escapeHtml(__('Contact Information')) ?></span></legend><br>
  20. <?= $block->getBlockHtml('formkey') ?>
  21. <input type="hidden" name="success_url" value="<?= $block->escapeUrl($block->getSuccessUrl()) ?>">
  22. <input type="hidden" name="error_url" value="<?= $block->escapeUrl($block->getErrorUrl()) ?>">
  23. <?= $block->getNameBlockHtml() ?>
  24. <?php if ($_company->isEnabled()): ?>
  25. <?= $_company->setCompany($block->getAddress()->getCompany())->toHtml() ?>
  26. <?php endif ?>
  27. <?php if ($_telephone->isEnabled()): ?>
  28. <?= $_telephone->setTelephone($block->getAddress()->getTelephone())->toHtml() ?>
  29. <?php endif ?>
  30. <?php if ($_fax->isEnabled()): ?>
  31. <?= $_fax->setFax($block->getAddress()->getFax())->toHtml() ?>
  32. <?php endif ?>
  33. </fieldset>
  34. <fieldset class="fieldset">
  35. <legend class="legend"><span><?= $block->escapeHtml(__('Address')) ?></span></legend><br>
  36. <?php $_streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?>
  37. <div class="field street required">
  38. <label for="street_1" class="label">
  39. <span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?></span>
  40. </label>
  41. <div class="control">
  42. <input type="text"
  43. name="street[]"
  44. value="<?= $block->escapeHtmlAttr($block->getStreetLine(1)) ?>"
  45. title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?>"
  46. id="street_1"
  47. class="input-text <?= $block->escapeHtmlAttr($_streetValidationClass) ?>"/>
  48. <div class="nested">
  49. <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
  50. <?php for ($_i = 1, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i < $_n; $_i++): ?>
  51. <div class="field additional">
  52. <label class="label" for="street_<?= /* @noEscape */ $_i + 1 ?>">
  53. <span><?= $block->escapeHtml(__('Street Address %1', $_i + 1)) ?></span>
  54. </label>
  55. <div class="control">
  56. <input type="text" name="street[]"
  57. value="<?= $block->escapeHtmlAttr($block->getStreetLine($_i + 1)) ?>"
  58. title="<?= $block->escapeHtmlAttr(__('Street Address %1', $_i + 1)) ?>"
  59. id="street_<?= /* @noEscape */ $_i + 1 ?>"
  60. class="input-text <?= $block->escapeHtmlAttr($_streetValidationClass) ?>">
  61. </div>
  62. </div>
  63. <?php endfor; ?>
  64. </div>
  65. </div>
  66. </div>
  67. <?php if ($this->helper('Magento\Customer\Helper\Address')->isVatAttributeVisible()) : ?>
  68. <div class="field taxvat">
  69. <label class="label" for="vat_id">
  70. <span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('vat_id') ?></span>
  71. </label>
  72. <div class="control">
  73. <input type="text"
  74. name="vat_id"
  75. value="<?= $block->escapeHtmlAttr($block->getAddress()->getVatId()) ?>"
  76. title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('vat_id') ?>"
  77. class="input-text <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('vat_id')) ?>"
  78. id="vat_id">
  79. </div>
  80. </div>
  81. <?php endif; ?>
  82. <div class="field city required">
  83. <label class="label" for="city"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('city') ?></span></label>
  84. <div class="control">
  85. <input type="text"
  86. name="city"
  87. value="<?= $block->escapeHtmlAttr($block->getAddress()->getCity()) ?>"
  88. title="<?= $block->escapeHtmlAttr(__('City')) ?>"
  89. class="input-text <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('city')) ?>"
  90. id="city">
  91. </div>
  92. </div>
  93. <div class="field region required">
  94. <label class="label" for="region_id">
  95. <span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?></span>
  96. </label>
  97. <div class="control">
  98. <select id="region_id" name="region_id"
  99. title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>"
  100. class="validate-select region_id" <?= /* @noEscape */ !$block->getConfig('general/region/display_all') ? ' disabled="disabled"' : '' ?>>
  101. <option value=""><?= $block->escapeHtml(__('Please select a region, state or province.')) ?></option>
  102. </select>
  103. <input type="text"
  104. id="region"
  105. name="region"
  106. value="<?= $block->escapeHtmlAttr($block->getRegion()) ?>"
  107. title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>"
  108. class="input-text validate-not-number-first <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region')) ?>"<?= !$block->getConfig('general/region/display_all') ? ' disabled="disabled"' : '' ?>/>
  109. </div>
  110. </div>
  111. <div class="field zip required">
  112. <label class="label" for="zip">
  113. <span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?></span>
  114. </label>
  115. <div class="control">
  116. <input type="text"
  117. name="postcode"
  118. value="<?= $block->escapeHtmlAttr($block->getAddress()->getPostcode()) ?>"
  119. title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?>"
  120. id="zip"
  121. class="input-text validate-zip-international <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('postcode')) ?>">
  122. <div role="alert" class="message warning" style="display:none">
  123. <span></span>
  124. </div>
  125. </div>
  126. </div>
  127. <div class="field country required">
  128. <label class="label" for="country"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('country_id') ?></span></label>
  129. <div class="control">
  130. <?= $block->getCountryHtmlSelect() ?>
  131. </div>
  132. </div>
  133. <?php if ($block->isDefaultBilling()): ?>
  134. <div class="message info">
  135. <span><?= $block->escapeHtml(__("It's a default billing address.")) ?></span>
  136. </div>
  137. <?php elseif ($block->canSetAsDefaultBilling()): ?>
  138. <div class="field choice set billing">
  139. <input type="checkbox" id="primary_billing" name="default_billing" value="1" class="checkbox">
  140. <label class="label" for="primary_billing">
  141. <span><?= $block->escapeHtml(__('Use as my default billing address')) ?></span>
  142. </label>
  143. </div>
  144. <?php else: ?>
  145. <input type="hidden" name="default_billing" value="1" />
  146. <?php endif; ?>
  147. <?php if ($block->isDefaultShipping()): ?>
  148. <div class="message info">
  149. <span><?= $block->escapeHtml(__("It's a default shipping address.")) ?></span>
  150. </div>
  151. <?php elseif ($block->canSetAsDefaultShipping()): ?>
  152. <div class="field choice set shipping">
  153. <input type="checkbox" id="primary_shipping" name="default_shipping" value="1" class="checkbox">
  154. <label class="label" for="primary_shipping">
  155. <span><?= $block->escapeHtml(__('Use as my default shipping address')) ?></span>
  156. </label>
  157. </div>
  158. <?php else: ?>
  159. <input type="hidden" name="default_shipping" value="1">
  160. <?php endif; ?>
  161. </fieldset>
  162. <div class="actions-toolbar">
  163. <div class="primary">
  164. <button type="submit"
  165. class="action save primary"
  166. data-action="save-address"
  167. title="<?= $block->escapeHtmlAttr(__('Save Address')) ?>">
  168. <span><?= $block->escapeHtml(__('Save Address')) ?></span>
  169. </button>
  170. </div>
  171. <div class="secondary">
  172. <a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
  173. <span><?= $block->escapeHtml(__('Go back')) ?></span>
  174. </a>
  175. </div>
  176. </div>
  177. </form>
  178. <script type="text/x-magento-init">
  179. {
  180. "#form-validate": {
  181. "addressValidation": {
  182. "postCodes": <?= /* @noEscape */ $block->getPostCodeConfig()->getSerializedPostCodes(); ?>
  183. }
  184. },
  185. "#country": {
  186. "regionUpdater": {
  187. "optionalRegionAllowed": <?= /* @noEscape */ $block->getConfig('general/region/display_all') ? 'true' : 'false' ?>,
  188. "regionListId": "#region_id",
  189. "regionInputId": "#region",
  190. "postcodeId": "#zip",
  191. "form": "#form-validate",
  192. "regionJson": <?= /* @noEscape */ $this->helper(\Magento\Directory\Helper\Data::class)->getRegionJson() ?>,
  193. "defaultRegion": "<?= (int) $block->getRegionId() ?>",
  194. "countriesWithOptionalZip": <?= /* @noEscape */ $this->helper(\Magento\Directory\Helper\Data::class)->getCountriesWithOptionalZip(true) ?>
  195. }
  196. }
  197. }
  198. </script>