Use submit button label of form for captcha submit button

[MAILPOET-4496]
This commit is contained in:
David Remer
2022-08-19 11:41:05 +03:00
committed by Veljko V
parent 538647946e
commit 87ced17813
2 changed files with 109 additions and 28 deletions

View File

@ -48,38 +48,12 @@ class CaptchaRenderer {
}
public function getCaptchaPageContent($sessionId) {
$this->captchaSession->init($sessionId);
$fields = [
[
'id' => 'captcha',
'type' => 'text',
'params' => [
'label' => __('Type in the characters you see in the picture above:', 'mailpoet'),
'value' => '',
'obfuscate' => false,
],
],
];
$form = array_merge(
$fields,
[
[
'id' => 'submit',
'type' => 'submit',
'params' => [
'label' => __('Subscribe', 'mailpoet'),
],
],
]
);
$captchaSessionForm = $this->captchaSession->getFormData();
$formId = 0;
$showSuccessMessage = !empty($_GET['mailpoet_success']);
$showErrorMessage = !empty($_GET['mailpoet_error']);
$formId = 0;
if (isset($captchaSessionForm['form_id'])) {
$formId = (int)$captchaSessionForm['form_id'];
} elseif ($showSuccessMessage) {
@ -93,6 +67,33 @@ class CaptchaRenderer {
return false;
}
$fields = [
[
'id' => 'captcha',
'type' => 'text',
'params' => [
'label' => __('Type in the characters you see in the picture above:', 'mailpoet'),
'value' => '',
'obfuscate' => false,
],
],
];
$submitBlocks = $formModel->getBlocksByTypes(['submit']);
$submitLabel = count($submitBlocks) && $submitBlocks[0]['params']['label'] ? $submitBlocks[0]['params']['label'] : __('Subscribe', 'mailpoet');
$form = array_merge(
$fields,
[
[
'id' => 'submit',
'type' => 'submit',
'params' => [
'label' => $submitLabel,
],
],
]
);
if ($showSuccessMessage) {
// Display a success message in a no-JS flow
return $this->renderFormMessages($formModel, $showSuccessMessage);