Skip to content

Commit 0d5e7f8

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop-express-lane-prs
- merged with '2.4-develop-temporary-three-prs' branch
2 parents f502d4a + 8fa24eb commit 0d5e7f8

File tree

2 files changed

+64
-31
lines changed
  • app/code/Magento/Customer/view/frontend/templates/form
  • dev/tests/integration/testsuite/Magento/Customer/Controller

2 files changed

+64
-31
lines changed

app/code/Magento/Customer/view/frontend/templates/form/edit.phtml

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,81 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
use Magento\Customer\Block\Widget\Name;
8+
79
/** @var \Magento\Customer\Block\Form\Edit $block */
810
?>
9-
<form class="form form-edit-account" action="<?= $block->escapeUrl($block->getUrl('customer/account/editPost')) ?>" method="post" id="form-validate" enctype="multipart/form-data" data-hasrequired="<?= $block->escapeHtmlAttr(__('* Required Fields')) ?>" autocomplete="off">
11+
<form class="form form-edit-account"
12+
action="<?= $block->escapeUrl($block->getUrl('customer/account/editPost')) ?>"
13+
method="post" id="form-validate"
14+
enctype="multipart/form-data"
15+
data-hasrequired="<?= $block->escapeHtmlAttr(__('* Required Fields')) ?>"
16+
autocomplete="off">
1017
<fieldset class="fieldset info">
1118
<?= $block->getBlockHtml('formkey') ?>
1219
<legend class="legend"><span><?= $block->escapeHtml(__('Account Information')) ?></span></legend><br>
13-
<?= $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Name::class)->setObject($block->getCustomer())->toHtml() ?>
20+
<?= $block->getLayout()->createBlock(Name::class)->setObject($block->getCustomer())->toHtml() ?>
1421

1522
<?php $_dob = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Dob::class) ?>
1623
<?php $_taxvat = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Taxvat::class) ?>
1724
<?php $_gender = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Gender::class) ?>
18-
<?php if ($_dob->isEnabled()) : ?>
25+
<?php if ($_dob->isEnabled()): ?>
1926
<?= $_dob->setDate($block->getCustomer()->getDob())->toHtml() ?>
2027
<?php endif ?>
21-
<?php if ($_taxvat->isEnabled()) : ?>
28+
<?php if ($_taxvat->isEnabled()): ?>
2229
<?= $_taxvat->setTaxvat($block->getCustomer()->getTaxvat())->toHtml() ?>
2330
<?php endif ?>
24-
<?php if ($_gender->isEnabled()) : ?>
31+
<?php if ($_gender->isEnabled()): ?>
2532
<?= $_gender->setGender($block->getCustomer()->getGender())->toHtml() ?>
2633
<?php endif ?>
2734
<div class="field choice">
28-
<input type="checkbox" name="change_email" id="change-email" data-role="change-email" value="1" title="<?= $block->escapeHtmlAttr(__('Change Email')) ?>" class="checkbox" />
29-
<label class="label" for="change-email"><span><?= $block->escapeHtml(__('Change Email')) ?></span></label>
35+
<input type="checkbox" name="change_email" id="change-email" data-role="change-email" value="1"
36+
title="<?= $block->escapeHtmlAttr(__('Change Email')) ?>" class="checkbox" />
37+
<label class="label" for="change-email">
38+
<span><?= $block->escapeHtml(__('Change Email')) ?></span>
39+
</label>
3040
</div>
3141
<div class="field choice">
32-
<input type="checkbox" name="change_password" id="change-password" data-role="change-password" value="1" title="<?= $block->escapeHtmlAttr(__('Change Password')) ?>"<?php if ($block->getChangePassword()) : ?> checked="checked"<?php endif; ?> class="checkbox" />
33-
<label class="label" for="change-password"><span><?= $block->escapeHtml(__('Change Password')) ?></span></label>
42+
<input type="checkbox" name="change_password" id="change-password" data-role="change-password" value="1"
43+
title="<?= $block->escapeHtmlAttr(__('Change Password')) ?>"
44+
<?php if ($block->getChangePassword()): ?> checked="checked"<?php endif; ?> class="checkbox" />
45+
<label class="label" for="change-password">
46+
<span><?= $block->escapeHtml(__('Change Password')) ?></span>
47+
</label>
3448
</div>
3549
</fieldset>
3650

3751
<fieldset class="fieldset password" data-container="change-email-password">
38-
<legend class="legend"><span data-title="change-email-password"><?= $block->escapeHtml(__('Change Email and Password')) ?></span></legend><br>
52+
<legend class="legend">
53+
<span data-title="change-email-password"><?= $block->escapeHtml(__('Change Email and Password')) ?></span>
54+
</legend><br>
3955
<div class="field email required" data-container="change-email">
4056
<label class="label" for="email"><span><?= $block->escapeHtml(__('Email')) ?></span></label>
4157
<div class="control">
42-
<input type="email" name="email" id="email" autocomplete="email" data-input="change-email" value="<?= $block->escapeHtmlAttr($block->getCustomer()->getEmail()) ?>" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" class="input-text" data-validate="{required:true, 'validate-email':true}" />
58+
<input type="email" name="email" id="email" autocomplete="email" data-input="change-email"
59+
value="<?= $block->escapeHtmlAttr($block->getCustomer()->getEmail()) ?>"
60+
title="<?= $block->escapeHtmlAttr(__('Email')) ?>"
61+
class="input-text"
62+
data-validate="{required:true, 'validate-email':true}" />
4363
</div>
4464
</div>
4565
<div class="field password current required">
46-
<label class="label" for="current-password"><span><?= $block->escapeHtml(__('Current Password')) ?></span></label>
66+
<label class="label" for="current-password">
67+
<span><?= $block->escapeHtml(__('Current Password')) ?></span>
68+
</label>
4769
<div class="control">
48-
<input type="password" class="input-text" name="current_password" id="current-password" data-input="current-password" autocomplete="off" />
70+
<input type="password" class="input-text" name="current_password" id="current-password"
71+
data-input="current-password"
72+
autocomplete="off" />
4973
</div>
5074
</div>
5175
<div class="field new password required" data-container="new-password">
5276
<label class="label" for="password"><span><?= $block->escapeHtml(__('New Password')) ?></span></label>
5377
<div class="control">
78+
<?php $minCharacterSets = $block->getRequiredCharacterClassesNumber() ?>
5479
<input type="password" class="input-text" name="password" id="password"
5580
data-password-min-length="<?= $block->escapeHtml($block->getMinimumPasswordLength()) ?>"
56-
data-password-min-character-sets="<?= $block->escapeHtml($block->getRequiredCharacterClassesNumber()) ?>"
81+
data-password-min-character-sets="<?= $block->escapeHtml($minCharacterSets) ?>"
5782
data-input="new-password"
5883
data-validate="{required:true, 'validate-customer-password':true}"
5984
autocomplete="off" />
@@ -68,7 +93,9 @@
6893
</div>
6994
</div>
7095
<div class="field confirmation password required" data-container="confirm-password">
71-
<label class="label" for="password-confirmation"><span><?= $block->escapeHtml(__('Confirm New Password')) ?></span></label>
96+
<label class="label" for="password-confirmation">
97+
<span><?= $block->escapeHtml(__('Confirm New Password')) ?></span>
98+
</label>
7299
<div class="control">
73100
<input type="password" class="input-text" name="password_confirmation" id="password-confirmation"
74101
data-input="confirm-password"
@@ -79,10 +106,14 @@
79106
<?= $block->getChildHtml('form_additional_info') ?>
80107
<div class="actions-toolbar">
81108
<div class="primary">
82-
<button type="submit" class="action save primary" title="<?= $block->escapeHtmlAttr(__('Save')) ?>"><span><?= $block->escapeHtml(__('Save')) ?></span></button>
109+
<button type="submit" class="action save primary" title="<?= $block->escapeHtmlAttr(__('Save')) ?>">
110+
<span><?= $block->escapeHtml(__('Save')) ?></span>
111+
</button>
83112
</div>
84113
<div class="secondary">
85-
<a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>"><span><?= $block->escapeHtml(__('Go back')) ?></span></a>
114+
<a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
115+
<span><?= $block->escapeHtml(__('Go back')) ?></span>
116+
</a>
86117
</div>
87118
</div>
88119
</form>
@@ -95,7 +126,7 @@
95126
var ignore = <?= /* @noEscape */ $_dob->isEnabled() ? '\'input[id$="full"]\'' : 'null' ?>;
96127

97128
dataForm.mage('validation', {
98-
<?php if ($_dob->isEnabled()) : ?>
129+
<?php if ($_dob->isEnabled()): ?>
99130
errorPlacement: function(error, element) {
100131
if (element.prop('id').search('full') !== -1) {
101132
var dobElement = $(element).parents('.customer-dob'),
@@ -109,20 +140,21 @@
109140
}
110141
},
111142
ignore: ':hidden:not(' + ignore + ')'
112-
<?php else : ?>
143+
<?php else: ?>
113144
ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
114145
<?php endif ?>
115146
});
116147

117148
});
118149
</script>
150+
<?php $changeEmailAndPasswordTitle = $block->escapeHtml(__('Change Email and Password')) ?>
119151
<script type="text/x-magento-init">
120152
{
121153
"[data-role=change-email], [data-role=change-password]": {
122154
"changeEmailPassword": {
123155
"titleChangeEmail": "<?= $block->escapeJs($block->escapeHtml(__('Change Email'))) ?>",
124156
"titleChangePassword": "<?= $block->escapeJs($block->escapeHtml(__('Change Password'))) ?>",
125-
"titleChangeEmailAndPassword": "<?= $block->escapeJs($block->escapeHtml(__('Change Email and Password'))) ?>"
157+
"titleChangeEmailAndPassword": "<?= $block->escapeJs($changeEmailAndPasswordTitle) ?>"
126158
}
127159
},
128160
"[data-container=new-password]": {

dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,12 @@ public function testEditAction()
396396
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode(), $body);
397397
$this->assertContains('<div class="field field-name-firstname required">', $body);
398398
// Verify the password check box is not checked
399-
$this->assertContains(
400-
'<input type="checkbox" name="change_password" id="change-password" '
401-
. 'data-role="change-password" value="1" title="Change&#x20;Password" class="checkbox" />',
402-
$body
403-
);
399+
$expectedString = <<<EXPECTED_HTML
400+
<input type="checkbox" name="change_password" id="change-password" data-role="change-password" value="1"
401+
title="Change&#x20;Password"
402+
class="checkbox" />
403+
EXPECTED_HTML;
404+
$this->assertContains($expectedString, $body);
404405
}
405406

406407
/**
@@ -416,12 +417,12 @@ public function testChangePasswordEditAction()
416417
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode(), $body);
417418
$this->assertContains('<div class="field field-name-firstname required">', $body);
418419
// Verify the password check box is checked
419-
$this->assertContains(
420-
'<input type="checkbox" name="change_password" id="change-password" '
421-
. 'data-role="change-password" value="1" title="Change&#x20;Password" checked="checked" '
422-
. 'class="checkbox" />',
423-
$body
424-
);
420+
$expectedString = <<<EXPECTED_HTML
421+
<input type="checkbox" name="change_password" id="change-password" data-role="change-password" value="1"
422+
title="Change&#x20;Password"
423+
checked="checked" class="checkbox" />
424+
EXPECTED_HTML;
425+
$this->assertContains($expectedString, $body);
425426
}
426427

427428
/**

0 commit comments

Comments
 (0)