Open FrDH opened 6 days ago
Sorry for the trouble you're experiencing @FrDH.
Can you provide me with a bit more information about your setup? 🙂
Thanks!
Thank you for the reply.
Here's a screenshot of the diagnostics page.
We're rendering the for with Twig, a modified version of the "Grid" example
Not that I know of. How could I check this? For the staging environment I had to turn off some of the redis, cache and session config (in app.php) because it still needs to be tweeked for Craft5. For local development (in DDEV) we had none of that config to begin with.
In the Craft4 starter project, Freeform remains to work as before. So my initial thought was some changed config or something. I realize this is probably an issue on our side, but any help is much appreciated.
Would it make any difference if we de-install Freeform, clear the DB from all freeform
tables and re-install Freeform?
I had a similar issue, Is the payload a hidden field or invissible, If it is an invissible field, could you try to set it to hidden. This did the trick for me. Also there is a change in code. You have to set fields: and use 'value'.
{% set overrideValues = [] %}
{% set overrideValues = {
'currentPage': (page != null and page.title != null) ? { "value": page.title },
'currentPageId': { "value": (page != null ? page.id ) },
'currentPageUrl': page != null and page.url != null ? { "value": page.url },
} %}
{{ form.render({ fieldIdPrefix: containerId, fields: overrideValues } ) }}
Also are you using caching like blitz cache? In that case you have to exclude a dynamic caching script let's say: templates/dynamic/freeform-token.twig And in this script you also have to add the payload. In my case:
{% set page = craft.app.elements.elementById(craft.app.request.get('page')) %}
{% set overrideValues = {
'currentPage': (page != null and page.title != null) ? { "value": page.title },
'currentPageId': { "value": craft.app.request.get('page') },
'currentPageUrl': page != null and page.url != null ? { "value": page.url },
} %}
{% set form = craft.freeform.form(craft.app.request.get('form'), { "fields": overrideValues }) %}
{% do form.registerContext %}
{{ {
hash: form.hash,
payload: form.payload,
csrf: {
name: craft.app.config.general.csrfTokenName,
value: craft.app.request.csrfToken,
}
}|json_encode|raw }}
See https://docs.solspace.com/craft/freeform/v5/guides/templating/caching-forms for the javascript to update the token an payload when using cache:
@tinusWCreators Thank you for the response. We set the overrideValues like this:
{% set values = [
page: 'xx'
] %}
{{ form.render({ fieldIdPrefix: containerId, values } ) }}
Which worked fine in Freeform5 on Craft4, is there any reason this wouldn't work (and cause the "missing payload" error) in Freeform5 on Craft5 ? I changed it to your way but that didn't make any difference.
We don't use caching but if we did, wouldn't we have the same issue in Craft4 ?
Just to be sure I added the {% do form.registerContext %}
to several places in the template (both before and after rendering the form) to no avail.
Thanks again for taking the time.
@tinusWCreators What do you mean by "Is the payload a hidden field or invissible"? It is a field that is automatically added to the page, I don't think I can edit it in either the CP nor the templates, or can I?
@FrDH I was refuring to the following issue: https://github.com/solspace/craft-freeform/issues/1570 In this issue the "Page" field would be of the type invisible in the CMS, and might therefor not be set.
Could you try again with something like
{% set values = [
page: { "value": "xx" },
] %}
{{ form.render({ fieldIdPrefix: "example-in-case-of-multiple-similar-forms-1", values } ) }}
What happened?
I recently updated our starter project to Craft5 and noticed the forms no longer can be submitted. Submitting the form returns the following error-messages:
This is both local (using DDEV) and on the staging server.
On first opening the page I can see a hidden input "freeform_payload" with an encoded value. After submitting and returning to the form with the error-messages, the value is different.
Errors and Stack Trace (if available)
How can we reproduce this?
Freeform Edition
Pro
Freeform Version
5.6.4
Craft Version
5.4.6
When did this issue start?
After upgrading from older Craft version
Previous Freeform Version
No response