-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
2,640 additions
and
2,794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function attachFormSubmitListener(formId) { | ||
var form = document.getElementById(formId); | ||
if (!form) { | ||
console.warn('Form with ID "' + formId + '" not found.'); | ||
return; | ||
} | ||
form.addEventListener('submit', function(e) { | ||
// Prevent standard form submission | ||
e.preventDefault(); | ||
// Submit the form via Ajax | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open(form.getAttribute('method'), form.getAttribute('action')); | ||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
form.innerHTML = xhr.responseText; // Update the current form's innerHTML | ||
} else { | ||
// Handle HTTP error responses (optional) | ||
console.error('Form submission failed with status: ' + xhr.status); | ||
} | ||
}; | ||
xhr.send(new URLSearchParams(new FormData(form)).toString()); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,8 @@ | ||
{% if form.xhr_submit == true %} | ||
{% do assets.addJs('plugin://form/assets/xhr-submitter.js', {'group': 'bottom', 'position': 'before'}) %} | ||
{% do assets.addInlineJs(" | ||
document.addEventListener('DOMContentLoaded', function() { | ||
var form = document.getElementById('" ~ form.id ~ "'); | ||
form.addEventListener('submit', function(e) { | ||
// prevent standard form submission | ||
e.preventDefault(); | ||
// submit the form via Ajax | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open(form.getAttribute('method'), form.getAttribute('action')); | ||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
document.getElementById('" ~ form.id ~ "').innerHTML = xhr.responseText; | ||
} | ||
}; | ||
xhr.send(new URLSearchParams(new FormData(form)).toString()); | ||
}); | ||
}); | ||
", {'group': 'bottom', 'position': 'before', 'priority': 100}) %} | ||
document.addEventListener('DOMContentLoaded', () => { | ||
attachFormSubmitListener('" ~ form.id ~ "'); | ||
});", | ||
{'group': 'bottom', 'position': 'before'}) %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<div class="modular-row form {{ page.header.class }}"> | ||
{{ content|raw }} | ||
{{ content|raw }} | ||
{% if config.plugins.form.modular_form_fix %} | ||
{% include "forms/form.html.twig" with {form: forms({route: page.route})} %} | ||
{% else %} | ||
{% include "forms/form.html.twig" %} | ||
{% endif %} | ||
</div> |
Oops, something went wrong.