Skip to content

Commit 48d0642

Browse files
committed
ACP2E-547: Magento forms can be submitted before the Google Recaptcha appears in the form
1 parent a96f0f7 commit 48d0642

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\ViewModel;
9+
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
12+
/**
13+
* Forgot password button view model
14+
*/
15+
class ForgotPasswordButton implements ArgumentInterface
16+
{
17+
/**
18+
* If Forgot password button should be disabled
19+
*
20+
* @return bool
21+
*/
22+
public function disabled(): bool
23+
{
24+
return false;
25+
}
26+
}

app/code/Magento/Customer/view/frontend/layout/customer_account_forgotpassword.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
</referenceBlock>
1818
<referenceContainer name="content">
1919
<block class="Magento\Customer\Block\Account\Forgotpassword" name="forgotPassword" template="Magento_Customer::form/forgotpassword.phtml">
20+
<arguments>
21+
<argument name="forgot_password_button_view_model" xsi:type="object">Magento\Customer\ViewModel\ForgotPasswordButton</argument>
22+
</arguments>
2023
<container name="form.additional.info" as="form_additional_info"/>
2124
</block>
2225
</referenceContainer>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// phpcs:disable Generic.Files.LineLength.TooLong
1010

1111
/** @var \Magento\Customer\Block\Account\Forgotpassword $block */
12+
/** @var \Magento\Customer\ViewModel\ForgotPasswordButton $forgotPasswordButtonViewModel */
13+
$forgotPasswordButtonViewModel = $block->getData('forgot_password_button_view_model');
1214
?>
1315
<form class="form password forget"
1416
action="<?= $block->escapeUrl($block->getUrl('*/*/forgotpasswordpost')) ?>"
@@ -27,13 +29,14 @@
2729
</fieldset>
2830
<div class="actions-toolbar">
2931
<div class="primary">
30-
<button type="submit" class="action submit primary"><span><?= $block->escapeHtml(__('Reset My Password')) ?></span></button>
32+
<button type="submit" class="action submit primary" id="send2" <?php if ($forgotPasswordButtonViewModel->disabled()): ?> disabled="disabled" <?php endif; ?>><span><?= $block->escapeHtml(__('Reset My Password')) ?></span></button>
3133
</div>
3234
<div class="secondary">
3335
<a class="action back" href="<?= $block->escapeUrl($block->getLoginUrl()) ?>"><span><?= $block->escapeHtml(__('Go back')) ?></span></a>
3436
</div>
3537
</div>
3638
</form>
39+
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
3740
<script type="text/x-magento-init">
3841
{
3942
"*": {

0 commit comments

Comments
 (0)