-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS-evaluation in ajax-enabled forms #7203
Comments
I can confirm the issue. |
To fix this we should IMO not evaluate the |
Or may be implement it as a mutation observer instead? |
I would prefer if a solution does not depend on a special widget. |
@asaage The solution will be done within the captcha widget's JavaScript. And any other widget of course needs to implement their JavaScript in a way that is independent from whether the form is submitted via AJAX or not (and that has always been the case). |
i figure, that would probably not solve the original issue i had in mp_forms and complicate enhancing formfield templates with js unneccessary 🤷♂️ |
May be ask on the Contao Community Forum or Community Slack for help regarding that issue.
I am not sure what you mean here. May be also ask on the Contao Community Forum or Community Slack for advice on how to handle forms that are submitted via AJAX properly (this is a general topic unrelated to Contao itself). |
The simplest (nonsense)example i can think of would be --- <p class="error"><?= $this->getErrorAsString() ?></p>
+++ <script>alert("<?= $this->getErrorAsString() ?>");</script> Which currently would not work in AJAX-form and will not if just the captcha widget is fixed. I would probably try fixing it somewhere around here: https://github.com/contao/contao/blob/5.x/core-bundle/contao/templates/forms/form_wrapper.html5#L28 Since Contao now comes with the ability to create AJAX forms i dont' think it's really "unrelated" to Contao itself. |
@zoglo not sure what is so funny about this reply? @asaage as already mentioned, you will always need to implement your JavaScript in an agnostic way. The way you want to implement it would also not work if you used other libraries that provide AJAX form submit functionalities like terminal42/contao-ajaxform or Turbo. |
|
Affected version(s)
5.3.7
Description
When a form is ajax enabled, script-tags are not loaded and executed (exept in the initial page-load).
Not sure, if that is by design, a known limitation or just a missing
eval();
somewhere.It occured first to me in a mp_form but the problem seems to be in the xhr-handler.
Such a script-tag exists especially in the captcha-field/widget (maybe others too).
To recreate: make a form, enable ajax, add an email-field, a captcha-field and a submit. In the FE force a validation error by submitting example@foo (mailaddress without tld). As a result the form will return with the usual errormessage but the captcha-field will be visible and not hidden as usual.
related:
The text was updated successfully, but these errors were encountered: