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