You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The submit button is hardwired into the form template. More flexibility with how to submit forms would be good.
Describe the solution you'd like
It should be possible to have different ways to trigger the submit event so that the form can do different things on submit. In particular, it would be nice to be able to navigate away from the form to a submission successful page or a second form page, etc after submit.
Describe alternatives you've considered
I have come up with my own workaround. I have modified templates/djangocms_form_builder/ajax_form.html to add a click event listener to any anchor elements on the form that then triggers the forms submit event. This means that any djangocms_link plugin added to the form will trigger submit. I have also removed the hardwired submit input from templates/djangocms_form_builder/bootstrap5/form.html
Here is a snippet of my modified code for ajax_form.html:
`{% addtoblock 'js' %}<script>
(function () {
function initForms() {
for (let form of document.getElementsByClassName('djangocms-form-builder-ajax-form')) {
djangocms_form_builder_form(form);
//custom code to allow links inserted into the form to trigger form submission
for(let link of form.getElementsByTagName('a')) {
link.addEventListener('click', function (event) {
form.submit();
});
}
}
}
window.addEventListener('DOMContentLoaded', initForms);
{% if request.toolbar and request.toolbar.edit_mode_active %}
CMS.$(window).on('cms-content-refresh', initForms);
{% endif %}
})();
</script>{% endaddtoblock %}`
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The submit button is hardwired into the form template. More flexibility with how to submit forms would be good.
Describe the solution you'd like
It should be possible to have different ways to trigger the submit event so that the form can do different things on submit. In particular, it would be nice to be able to navigate away from the form to a submission successful page or a second form page, etc after submit.
Describe alternatives you've considered
I have come up with my own workaround. I have modified templates/djangocms_form_builder/ajax_form.html to add a click event listener to any anchor elements on the form that then triggers the forms submit event. This means that any djangocms_link plugin added to the form will trigger submit. I have also removed the hardwired submit input from templates/djangocms_form_builder/bootstrap5/form.html
Here is a snippet of my modified code for ajax_form.html:
`{% addtoblock 'js' %}<script>
(function () {
function initForms() {
for (let form of document.getElementsByClassName('djangocms-form-builder-ajax-form')) {
</script>{% endaddtoblock %}`
The text was updated successfully, but these errors were encountered: