Since the update from grav-plugin-form 3.0.5, my ajax forms do not work as expected. I am not sure if this is caused by the plugin or by the way Grav manages languages.
This form worked as expected until the update:
title: 'Contact'
cache_enable: false
form:
action: /contact
name: contact-form
template: form-messages
refresh_prevention: true
With this JS:
$.ajax({
url: form.attr('action'),
type: form.attr('method'),
data: form.serialize(),
dataType: 'html',
success: function() {},
beforeSend: function() {},
complete: function(result) {}
});
When the website has multiple languages, and paths are prefixed with the language code, this code no longer works since the update. There is an issue with redirection.
I put in place a temporary fix by hardcoding one language to the action path:
form:
action: /en/contact
It works, but it is not a good long-term solution: is this a bug of grav-plugin-form? Of Grav? Or is there a fundamentally better (and bug-free) way of submitting an ajax form in Grav?