Skip to content

Instantly share code, notes, and snippets.

@wesleyalmd
Created December 22, 2020 16:29
Show Gist options
  • Save wesleyalmd/216f3316ee7f05223d4c07770fdc1191 to your computer and use it in GitHub Desktop.
Save wesleyalmd/216f3316ee7f05223d4c07770fdc1191 to your computer and use it in GitHub Desktop.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php
/**
* Create account form template
*
* @var $block \Magento\Customer\Block\Form\Register
*/
?>
<?= $block->getChildHtml('form_fields_before') ?>
<?php /* Extensions placeholder */ ?>
<?= $block->getChildHtml('customer.form.register.extra') ?>
<form class="form create account form-create-account" action="<?= /* @escapeNotVerified */ $block->getPostActionUrl() ?>" method="post" id="form-validate" enctype="multipart/form-data" autocomplete="off">
<?= /* @noEscape */ $block->getChildHtml('form_fields_before_in_form') ?>
<?= /* @noEscape */ $block->getBlockHtml('formkey'); ?>
<fieldset class="fieldset create info">
<legend class="legend"><span><?= /* @escapeNotVerified */ __('Personal Information') ?></span></legend><br>
<input type="hidden" name="success_url" value="<?= /* @escapeNotVerified */ $block->getSuccessUrl() ?>"/>
<input type="hidden" name="error_url" value="<?= /* @escapeNotVerified */ $block->getErrorUrl() ?>"/>
<?= $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Name')->setObject($block->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
<?php $_dob = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Dob') ?>
<?php if ($_dob->isEnabled()): ?>
<div class="field date field-dob required">
<label class="label" for="dob"><span>Fecha de nacimiento</span></label>
<div class="control">
<input type="text" class="input-text" id="example-date" name="dob" data-validate="{required:true}" autocomplete="off" aria-required="true" readonly="readonly" />
</div>
</div>
<script>
require([
'jquery',
'mage/translate',
'mage/calendar'
], function ($, $t) {
$('#example-date').calendar({
dateFormat:'dd-mm-yyyy',
yearRange: '1930:-18',
maxDate: "-18y -1m",
monthNames: ['Enero','Febrero','Marzo','Abril','May','Junio','Julio',
'Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'],
dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],
dayNamesShort: ['Do','Lu','Ma','Mi','Ju','Vi','Sa'],
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sa'],
changeMonth: true,
changeYear: true,
showButtonPanel: false,
showWeek: false,
buttonText: 'Selecciona fecha', changeMonth: true, changeYear: true, showOn: 'both'
});
})
</script>
<?php endif ?>
<?php $_taxvat = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Taxvat') ?>
<?php if ($_taxvat->isEnabled()): ?>
<?= $_taxvat->setTaxvat($block->getFormData()->getTaxvat())->toHtml() ?>
<?php endif ?>
<?php $_gender = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Gender') ?>
<?php if ($_gender->isEnabled()): ?>
<?= $_gender->setGender($block->getFormData()->getGender())->toHtml() ?>
<?php endif ?>
<?php $customerAttributes = $block->getChildBlock('customer_form_user_attributes');?>
<?php if ($customerAttributes): ?>
<?php $customerAttributes->setEntityType('customer')->setShowContainer(false);?>
<?php $block->restoreSessionData($customerAttributes->getMetadataForm());?>
<?= $customerAttributes->toHtml() ?>
<?php endif;?>
</fieldset>
<?php if ($block->getShowAddressFields()): ?>
<fieldset class="fieldset address">
<legend class="legend"><span><?= /* @escapeNotVerified */ __('Address Information') ?></span></legend><br>
<input type="hidden" name="create_address" value="1"/>
<div class="field company">
<label for="company" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('company') ?></span></label>
<div class="control">
<input type="text" name="company" id="company" value="<?= $block->escapeHtml($block->getFormData()->getCompany()) ?>" title="<?= /* @escapeNotVerified */ __('Company') ?>" class="input-text <?= /* @escapeNotVerified */ $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('company') ?>"/>
</div>
</div>
<div class="field telephone required">
<label for="telephone" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('telephone') ?></span></label>
<div class="control">
<input type="text" name="telephone" id="telephone" value="<?= $block->escapeHtml($block->getFormData()->getTelephone()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('telephone') ?>" class="input-text <?= /* @escapeNotVerified */ $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('telephone') ?>"/>
</div>
</div>
<?php $_streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?>
<div class="field street required">
<label for="street_1" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?></span></label>
<div class="control">
<input type="text" name="street[]" value="<?= $block->escapeHtml($block->getFormData()->getStreetLine(1)) ?>" title="<?= /* @escapeNotVerified */ __('Street Address') ?>" id="street_1" class="input-text <?= /* @escapeNotVerified */ $_streetValidationClass ?>"/>
<div class="nested">
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
<?php for ($_i = 2, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?>
<div class="field additional">
<label class="label" for="street_<?= /* @escapeNotVerified */ $_i ?>">
<span><?= /* @escapeNotVerified */ __('Street Address %1', $_i) ?></span>
</label>
<div class="control">
<input type="text" name="street[]" value="<?= $block->escapeHtml($block->getFormData()->getStreetLine($_i - 1)) ?>" title="<?= /* @escapeNotVerified */ __('Street Address %1', $_i) ?>" id="street_<?= /* @escapeNotVerified */ $_i ?>" class="input-text <?= /* @escapeNotVerified */ $_streetValidationClass ?>"/>
</div>
</div>
<?php endfor; ?>
</div>
</div>
</div>
<div class="field required">
<label for="city" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('city') ?></span></label>
<div class="control">
<input type="text" name="city" value="<?= $block->escapeHtml($block->getFormData()->getCity()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('city') ?>" class="input-text <?= /* @escapeNotVerified */ $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('city') ?>" id="city"/>
</div>
</div>
<div class="field region required">
<label for="region_id" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?></span></label>
<div class="control">
<select id="region_id" name="region_id" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>" class="validate-select" style="display:none;">
<option value=""><?= /* @escapeNotVerified */ __('Please select a region, state or province.') ?></option>
</select>
<input type="text" id="region" name="region" value="<?= $block->escapeHtml($block->getRegion()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>" class="input-text <?= /* @escapeNotVerified */ $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region') ?>" style="display:none;"/>
</div>
</div>
<div class="field zip required">
<label for="zip" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?></span></label>
<div class="control">
<input type="text" name="postcode" value="<?= $block->escapeHtml($block->getFormData()->getPostcode()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?>" id="zip" class="input-text validate-zip-international <?= /* @escapeNotVerified */ $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('postcode') ?>" data-validate="{'required':true, 'validate-zip-international':true}"/>
</div>
</div>
<div class="field country required">
<label for="country" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('country_id') ?></span></label>
<div class="control">
<?= $block->getCountryHtmlSelect() ?>
</div>
</div>
<?php $addressAttributes = $block->getChildBlock('customer_form_address_user_attributes');?>
<?php if ($addressAttributes): ?>
<?php $addressAttributes->setEntityType('customer_address'); ?>
<?php $addressAttributes->setFieldIdFormat('address:%1$s')->setFieldNameFormat('address[%1$s]');?>
<?php $block->restoreSessionData($addressAttributes->getMetadataForm(), 'address');?>
<?= $addressAttributes->setShowContainer(false)->toHtml() ?>
<?php endif;?>
<input type="hidden" name="default_billing" value="1"/>
<input type="hidden" name="default_shipping" value="1"/>
</fieldset>
<?php endif; ?>
<fieldset class="fieldset create account" data-hasrequired="<?= /* @escapeNotVerified */ __('* Required Fields') ?>">
<legend class="legend"><span><?= /* @escapeNotVerified */ __('Sign-in Information') ?></span></legend><br>
<div class="field required">
<label for="email_address" class="label"><span><?= /* @escapeNotVerified */ __('Email') ?></span></label>
<div class="control">
<input type="email" name="email" id="email_address" autocomplete="email" value="<?= $block->escapeHtml($block->getFormData()->getEmail()) ?>" title="<?= /* @escapeNotVerified */ __('Email') ?>" class="input-text" data-validate="{required:true, 'validate-email':true}"/>
<span class="hiraoka-msg-form">Tu correo electrónico será utilizado como tu usuario</span>
</div>
</div>
<div class="field password required">
<label for="password" class="label"><span><?= /* @escapeNotVerified */ __('Password') ?></span></label>
<div class="control">
<input type="password" name="password" id="password"
title="<?= /* @escapeNotVerified */ __('Password') ?>"
class="input-text"
data-password-min-length="<?= $block->escapeHtml($block->getMinimumPasswordLength()) ?>"
data-password-min-character-sets="<?= $block->escapeHtml($block->getRequiredCharacterClassesNumber()) ?>"
data-validate="{required:true, 'validate-customer-password':true}"
autocomplete="off">
<span class="hiraoka-msg-form">Tu contraseña debe ser de al menos 8 caracteres y contener al menos un número y una mayúscula.</span>
<div id="password-strength-meter-container" data-role="password-strength-meter" aria-live="polite">
<div id="password-strength-meter" class="password-strength-meter">
<?= /* @escapeNotVerified */ __('Password Strength') ?>:
<span id="password-strength-meter-label" data-role="password-strength-meter-label">
<?= /* @escapeNotVerified */ __('No Password') ?>
</span>
</div>
</div>
</div>
</div>
<div class="field confirmation required">
<label for="password-confirmation" class="label"><span><?= /* @escapeNotVerified */ __('Confirm Password') ?></span></label>
<div class="control">
<input type="password" name="password_confirmation" title="<?= /* @escapeNotVerified */ __('Confirm Password') ?>" id="password-confirmation" class="input-text" data-validate="{required:true, equalTo:'#password'}"/>
<span class="hiraoka-msg-form">Tu contraseña debe ser de al menos 8 caracteres y contener al menos un número y una mayúscula.</span>
</div>
</div>
<?= $block->getChildHtml('form_additional_info') ?>
</fieldset>
<?php if ($block->isNewsletterEnabled()): ?>
<div class="field choice newsletter">
<input type="checkbox" name="is_subscribed" title="<?= /* @escapeNotVerified */ __('Acepto el uso de mi información para fines adicionales') ?>" value="1" id="is_subscribed"<?php if ($block->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox"/>
<label for="is_subscribed" class="label">Acepto el uso de mi información para <a data-src="#fancy-uso-informacion" class="custom-fancybox" href="javascript:;">fines adicionales</a>, Quiero recibir las mejores ofertas promocionales.</label>
</div>
<div class="field choice newsletter" style="display: none">
<input type="checkbox" disabled checked>
<label class="label" id="already_subscribed">Este correo ya ha aceptado nuestra política de <a data-src="#fancy-uso-informacion" class="custom-fancybox" href="javascript:;">fines adicionales</a>. Para dejar de recibir comunicaciones escribir a <a href="mailto:[email protected]">[email protected]</a>.</label>
</div>
<?php /* Extensions placeholder */ ?>
<?= $block->getChildHtml('customer.form.register.newsletter') ?>
<?php endif ?>
<div class="filed custom-field required check-term-and-conditions">
<div class="control">
<input type="checkbox" id="custom-term-and-conditions" name="custom-term-and-conditions" data-validate="{required:true}" />
<label for="custom-term-and-conditions">He leído y acepto los <a data-src="#fancy-term-and-conditions" class="custom-fancybox" href="javascript:;">términos y condiciones</a> y <a data-src="#fancy-proteccion-de-datos" class="custom-fancybox" href="javascript:;">Politicas de protección de datos personales</a></label>
</div>
</div>
<div class="actions-toolbar">
<div class="primary">
<button id="create-account" type="submit" class="action submit primary" title="<?= /* @escapeNotVerified */ __('Create an Account') ?>"><span><?= /* @escapeNotVerified */ __('Create an Account') ?></span></button>
</div>
<div class="secondary">
<a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>"><span><?= /* @escapeNotVerified */ __('Back') ?></span></a>
</div>
</div>
<div style="display: none;" id="fancy-uso-informacion">
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('modal-uso-informacion')->toHtml(); ?>
</div>
<div style="display: none;" id="fancy-term-and-conditions">
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('modal-terminos-y-condiciones')->toHtml(); ?>
</div>
<div style="display: none;" id="fancy-proteccion-de-datos">
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('modal-proteccion-de-datos')->toHtml(); ?>
</div>
</form>
<script>
require([
'jquery',
'mage/mage'
], function($) {
function onlyNumbers($value) {
const str = $value.val().replace(/[^0-9]/g, '');
$value.val(str);
}
function onlyAlpha($value) {
const str = $value.val().replace(/[^a-zà-ú ]/gi, '');
$value.val(str);
}
$('#firstname').keyup(function() {
onlyAlpha($(this));
});
$('#middlename').keyup(function() {
onlyAlpha($(this));
});
$('#lastname').keyup(function() {
onlyAlpha($(this));
});
var phoneBlacklist = ['90000000', '91111111', '92222222', '93333333', '94444444', '95555555', '96666666', '97777777', '98888888', '99999999'];
$('#cellphone').keyup(function() {
const value = $(this);
for (let index = 0; index < phoneBlacklist.length; index++) {
if (phoneBlacklist[index] === value.val()) {
value.val('');
}
}
});
$('#cellphone').before('<span class="input-addon">51</span>');
var documentBlacklist = ['00000000', '00000001', '00000004', '00000008', '00000111', '00000145', '00000478', '00001111', '00011111', '00111111', '01111111', '08888888', '10101010', '11111111', '12345678', '22222222', '33333333', '44444444', '55555555', '66666666', '77777777', '88888888', '99999999'];
$('#document_number').keyup(function() {
const value = $(this);
for (let index = 0; index < documentBlacklist.length; index++) {
if (documentBlacklist[index] === value.val()) {
value.val('');
}
}
});
});
</script>
<script type="text/x-magento-init">
{
<?php if ($block->getShowAddressFields()): ?>
"#country": {
"regionUpdater": {
"optionalRegionAllowed": <?= /* @escapeNotVerified */ ($block->getConfig("general/region/display_all") ? "true" : "false") ?>,
"regionListId": "#region_id",
"regionInputId": "#region",
"postcodeId": "#zip",
"form": "#form-validate",
"regionJson": <?= /* @escapeNotVerified */ $this->helper(\Magento\Directory\Helper\Data::class)->getRegionJson() ?>,
"defaultRegion": "<?= /* @escapeNotVerified */ $block->getFormData()->getRegionId() ?>",
"countriesWithOptionalZip": <?= /* @escapeNotVerified */ $this->helper(\Magento\Directory\Helper\Data::class)->getCountriesWithOptionalZip(true) ?>
}
},
<?php endif; ?>
"*": {
"Magento_CustomerCustomAttributes/validation": {
"ignore": <?= (int) ($_dob->isEnabled() || $customerAttributes->hasUserDefinedAttributes()) ?>,
"hasUserDefinedAttributes": <?= (int) $customerAttributes->hasUserDefinedAttributes() ?>,
"isDobEnabled": <?= (int) $_dob->isEnabled() ?>,
"disableAutoComplete": true,
"mixins": [
"Magento_CustomerCustomAttributes/error-placement",
"Magento_CustomerCustomAttributes/validation-ignore"
]
},
"Xpectrum_Customer/js/action/registration": {
"ajaxUrl": "<?php echo $block->getAjaxUrl(); ?>"
}
},
".field.password": {
"passwordStrengthIndicator": {
"formSelector": "form.form-create-account"
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment