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