Hidden form data missing between for submission & wordpress
-
Hi,
I’m having an issue where some data I’m adding into a hidden field seems to be disappearing from when the from is submitted to when it arrives in my submissions in WP.
If I use a URL such as https://www.lazenby.co.uk/contact/?gclid=today
The vale of the gclid param is inserted into the hidden field. When I inspect the field with Dev tools, I can see my value is inserted. And when I lok at network traffic, it appears that the value is also sent with the form.
It’s just that when I look at the submissions in formiantor/WP backend, that hidden field is blank.
This is about the limit of my knowledge but as far as I can see everything is setup correctly
the hidden form name is hidden-1
Thanks for any help.
Mark
The page I need help with: [log in to see the link]
-
Hi @manageuser
Sorry to hear you are having this issue.
I tried to replicate it on my end however the value got saved on ajax load and regular form rendering:
https://monosnap.com/file/njLGssMvZtugRSHUwlia60gyKj1Eqs
I do see the value on your source code as well.
Could you export the form and share using the pastebin.com so we can take a deeper look?
Best Regards
Patrick FreitasHi @manageuser
Thank you for your form. It seems you have setup both hidden fields incorrectly. If you want to take value from URL into hidden field without pre-populate field from previous page from another form, you need to set up your hidden fields like this:
Default Value (optional) -> Query Parameter
not
Default Value (optional) -> Custom Value
which is right now in your form.For example, as soon you will set up Query Parameter as gclid, then in your submissions you should see “today”, based on your URL example.
Kind Regards,
KrisHi Kris,
Thanks for the quick reply. We are actually passing the parameter in via a variable in GTM rather than from the URL.
The reason being is that mostly the users land on a different page than the form, so the query parameter in the URL is lost between pages. We are storing it as a variable instead and passing it into the form.
I can see that this stage is working correctly, the value is passed to the form from the variable, and appears to be sent with the form – so all this is correct – it’s just not appearing in WP/forminator.
THanks,
Mark
ACtually sorry I possibly misread your reply. I’ll try changing to query parameter now and try that. Does that still stand for passing in via a variable?
Testing it now..
Hi Kris,
That didn’t work, I think because we need it as a custom value as passing in via a variable.
If you go to https://www.lazenby.co.uk/?gclid=monday-7th as an example, you can place anything as the query parameter, then head to the contact page and you can see in dev tools that hidden-1 field is being populated.
When I submit it, I can see it in the network traffic but it just doesn’t appear in the form submissions.
thanks,
mark
Hi @manageuser
Thanks for response and additional explanation!
This wasn’t mentioned in your initial post:
If you go to https://www.lazenby.co.uk/?gclid=monday-7th as an example, you can place anything as the query parameter, then head to the contact page and you can see in dev tools that hidden-1 field is being populated.
and it makes all the difference because it means you must be using some additional custom code to populate the hidden field. Such functionality is not part of the Frominator and cannot be achieved (and never could) without custom code.
So I’m pretty sure you got some code to populate the field value from a cookie or other source. This will not work anymore because there were additional security measures applied to the form with one of previous releases (1.24 if I remember correctly) and the value of hidden field is validated and sanitized against its configuration.
In other words, if you set field to “custom value” option, it will only save whatever is set in field settings – what you override there with your custom code will be removed and not stored.
—–
There are two workarounds for that:
1. very simple one: replace the hidden field with “input” type field and hide that field with CSS (with CSS, not with field’s visibility conditions!); you’ll also need to adjust field ID accordingly in your code.
2. or switch the hidden field to be set to user “Query Var” and define query var name (as suggested by Kris earlier) and then modify your code to inject/maintain query var related request URLs.
The first solution, however, would be simpler and require least modifications (and would work as fine as it used to with hidden field in the past).
Kind regards,
AdamHi Adam,
Great thanks for the info. Using CSS for the first workaround is slightly above my knowledge, is there any way you could add what CSS I need to use?
For the second part of it ” you’ll also need to adjust field ID accordingly in your code.” would that be adjusting the ID so that it is static?
Thanks,
Mark
Hi @manageuser
Using CSS for the first workaround is slightly above my knowledge, is there any way you could add what CSS I need to use?
Actually, it can be even simpler than CSS (I missed it, sorry!):
Once you add the “input” type field simply go to that field’s “Styling” setting and put this (exactly) in the “Additional CSS Classes” option:
forminator-hiddenThis way this field will be hidden.
For the second part of it ” you’ll also need to adjust field ID accordingly in your code.” would that be adjusting the ID so that it is static?You just need to change field ID. If in your code you’re using eg “hidden-1” and the new field is “text-1”, you simply need to replace “hidden-1” string with “text-1” in your code.
Kind regards,
Adam-
This reply was modified 2 years, 9 months ago by
Laura - WPMU DEV Support. Reason: typo
Thanks again! All making sense so far and I’ve hidden that. Now the data isn’t inserting into the field when I test it.
I’ve added a screnshot here, I guess it’s the first ID I should be using id=”text-1″ ?
https://paste.pics/883495b90e3ffe41900065df1a9932f4
Mark
Hi @manageuser
You should be using “text-1”.
If you still have troubles with this, please share the custom code that you are using and we’ll look into it and confirm what/how should be changed there.
Best regards,
AdamStill no luck..
This is the code in GTM I’m using;
<script> (function() { var el = document.getElementById('text-1'); if (el) { el.value = '{{cookie - set from gclid}}'; } })(); </script>I’ve also tried it with with one of the other displayed fields, and using a static value;
<script> (function() { var el = document.getElementById('name-1'); if (el) { el.value = "test text"; } })(); </script>But neither are working.
Thanks,
Mark
Hi,
Thanks for all your help on this I’ve got it working now.. I think there was something wrong with my placements of ” and ‘ in the code, I’ve changed it a little and seems to be good.
Code I’m using now is;
<script> document.querySelector("input[name='text-1']").value = '{{set_fieldWithData}}'; </script>Seems to be working good and I can see them in submissions. Thanks again for all the help.
Mark
-
This reply was modified 2 years, 9 months ago by
markp.
-
This reply was modified 2 years, 9 months ago by
The topic ‘Hidden form data missing between for submission & wordpress’ is closed to new replies.