Query Parameter
-
If I have an URL:
https://Sitename/Page1And there will be a copy called:
https://Sitename/Page2How do I do a query parameter that picks up the Page 1 or Page 2 bit?
I want to use them in a hidden field to decide which Select fields are shown/activated on a page.
-
Changed my mind.
Using the Hidden Field to show Page Id ….. ie: 170 for the current pageBut when using Visibility Logic – it doesn’t hide when the field is 170 (because the rule was to only show when page id is 182)
-
This reply was modified 5 years, 8 months ago by
Imran Siddiq.
Would be really good if someone can workout how I make the Hidden Field pickup the Post ID of a page.
Because at the moment it’s not working.
Hi @flickimp,
You can find more information on how to use the pre-populated fields on our docs page here:
https://premium.wpmudev.org/docs/wpmu-dev-plugins/forminator/#pre-populate-form-field-valuesHowever, I’m not sure that I understand completely what is supposed to happen so would you mind explaining a bit with step by step on how the forms should work and what should happen?
Also, about the Page ID not working, are you saying that it doesn’t pick up the ID in the current form or that it doesn’t pass that on the second form?
Cheers,
PredragI hope this helps;
Say you got to a Webpage https://www.fake.com/Location1
The Page ID for this is 155
I have a form that has 10 Datepickers, because each DataPicker is unique per location (in terms of selectable days etc)
When the user goes to this page, the datepicker for this form has a rule = Only show when the Hidden Field = 155
And the Hidden Field was set up to be the Post/Page ID
But at the moment, when you go to the page, it shows all 10 datepickers and isn’t restricting itself to only show 1, because the other 9 pages have different Page IDs.
Hello @flickimp ,
It looks like Hidden Field is setting the value to Page ID correctly, however, it’s not working with the Conditional settings of other fields.
I’ve reached out to the Forminator team about this issue to see if there is way to make it work. We will keep you updated.kind regards,
KasiaHello @flickimp ,
I’ve talked with developers and this is a bug with the hidden field. Right now it can’t be used for the visibility rules. I’ve reported that bug and developers will take care of it.
kind regards,
KasiaThanks
Is there a way to not use a hidden field?
So could I use a Name/Text field that just pulls in the Page ID?And then I can use that for the visibility rules.
Hi @flickimp
I hope you are doing well.
You can a query parameter for this, the same way that @wpmudev-support1 suggested:
https://premium.wpmudev.org/docs/wpmu-dev-plugins/forminator/#pre-populate-form-field-valuesHowever, for this, you would need to add the parameter to the URL, for example
/my-form/?id=10I pinged our developers to check if there any other way for that may be using some JavaScript.
We will update once hearing back from the developers.
Best Regards
Patrick FreitasHi @flickimp
I just received an update from our developers.
I found a workaround that you can try using some custom JavaScript.
On this thread, you can find a custom code that collects the page ID using JavaScipt: https://stackoverflow.com/a/43809212
Once the ID stored on a variable, you can set the value on your regular text field using:
document.getElementById('forminator-field-text-1').value=id;And then trigger the conditionals using:
jQuery("#forminator-field-text-1").trigger('change');https://monosnap.com/file/J4t5egaFJkt0yLtqr9Xmpc6NNkRfVh
Just replace the forminator-field-text-1 to your field ID.
https://monosnap.com/file/mxlSFjNmYgLWSK2LF30eTtkJPzCHcJ
Most of the time the theme options has the field to add custom JavaScripts code, but in case it doesn’t have, you can use a plugin like https://wordpress.org/plugins/custom-css-js/ just make sure the JS loads on the footer.
Let us know the result you got.
Best Regards
Patrick Freitas -
This reply was modified 5 years, 8 months ago by
The topic ‘Query Parameter’ is closed to new replies.