terminal42/contao-mp_forms

javascript-loading / execution in ajax-enabled forms

Closed this issue · 4 comments

When an mp-form has ajax enabled i noticed that script-tags are not loaded and executed (exept when they originate from the first page of the form)
Not sure, if that is by design, a known limitation or just a missing eval(); somewhere.
I opted for ajax mainly to prevent the page from scrolling up during pageflips (with ajax turned off everything works as expected)
Such a script-tag exists especially in the captcha-field/widget (maybe others too) which i'd like to put on the last page of my mp-form. There might be other js-enhanced form-elements down the road.
https://community.contao.org/de/showthread.php?86809-mp_forms-mit-captcha&p=584074

I guess that's not related to mp_forms, really. It would be the same with any form field. What happens if you submit and have an error for example? The form fields would initialize again and JS should fail if what you're saying is correct.

I guess that's not related to mp_forms, really.

That's true...
Well error messages just appear i didnt notice any difference but the captcha is kind of broken in the same way.
I'm closing this here.
I'm just not sure if it is a bug or if it was left out because of security implications or if there is even a simple fix for it.

Yeah, it would need to be fixed in the core :)

The core must not execute eval() on an AJAX request's response. Any JavaScript must be implemented in an agnostic way.