diff --git a/Resources/Private/Fusion/Root.fusion b/Resources/Private/Fusion/Root.fusion index 48b9298..c9a5ff4 100644 --- a/Resources/Private/Fusion/Root.fusion +++ b/Resources/Private/Fusion/Root.fusion @@ -15,6 +15,6 @@ prototype(Neos.Neos:Page) { path = 'resource://Onedrop.Form.Hubspot/Public/JavaScript/captcha.js' } } - @if.hasFormAndIsLiveAndActive = ${q(node).children('[instanceof Neos.Neos:ContentCollection]').find('[instanceof Onedrop.Form.Hubspot:Content.Form]').is() && node.context.live && Configuration.setting('Onedrop.Form.Hubspot.recaptcha_v2.enableRecaptcha')} + @if.hasFormAndIsLiveAndActive = ${q(node).find('[instanceof Onedrop.Form.Hubspot:Content.Form]').is() && node.context.live && Configuration.setting('Onedrop.Form.Hubspot.recaptcha_v2.enableRecaptcha')} } } diff --git a/Resources/Private/Translations/de/ValidationErrors.xlf b/Resources/Private/Translations/de/ValidationErrors.xlf index 317bd4e..e7203a8 100644 --- a/Resources/Private/Translations/de/ValidationErrors.xlf +++ b/Resources/Private/Translations/de/ValidationErrors.xlf @@ -5,7 +5,7 @@ Captcha could not be validated. - Captcha konnte nicht validiert werden.. + Captcha konnte nicht validiert werden. diff --git a/Resources/Public/JavaScript/captcha.js b/Resources/Public/JavaScript/captcha.js index ddc5d87..844fee2 100644 --- a/Resources/Public/JavaScript/captcha.js +++ b/Resources/Public/JavaScript/captcha.js @@ -65,13 +65,14 @@ function rebuildCaptcha() { let activeButton = null; function submitForm() { - let formId = activeButton.name.match('((\\w|\\d)+-)+(\\w|\\d)+')[0]; - let form = document.querySelector('form#' + formId); - let hiddenField = document.createElement('input'); - hiddenField.name = activeButton.name; - hiddenField.setAttribute('value', activeButton.value); - hiddenField.hidden = true; - form.appendChild(hiddenField); + let form = activeButton.closest('form'); + if (activeButton.name && activeButton.value) { + let hiddenField = document.createElement('input'); + hiddenField.name = activeButton.name; + hiddenField.setAttribute('value', activeButton.value); + hiddenField.hidden = true; + form.appendChild(hiddenField); + } form.submit(); } @@ -79,13 +80,17 @@ function submitForm() { * add token to inputs and submit form * * @param token + * @returns {Promise|Promise|u} */ function invisibleCallback(token) { - if(activeButton) { - setValuesForRecaptchas(token); - submitForm(); - activeButton = null; - } + return new Promise(function(resolve) { + if (activeButton) { + setValuesForRecaptchas(token); + submitForm(); + activeButton = null; + resolve(); + } + }); } /**