How do I pass custom values to a gravity form? This custom value is needed to dynamically populate the fields.
Also how do I set hidden form values?
How do I pass custom values to a gravity form? This custom value is needed to dynamically populate the fields.
Also how do I set hidden form values?
You can pass custom values to a page where Gravity Forms is embedded in the query string.
Example: http://example.com/page-with-form/?email=username@gmail.com
That will send the value "username@gmail.com" to the form embedded in the WordPress page with the slug of "page-with-form" and populate to form field with a parameter name of "email" (this you have to configure in your form.)
For hidden form values, what do you mean?
by hidden, I mean:
<input type="hidden" name="email" value="username@gmail.com">
so as part of the form submission, a field and value are submitted, but are invisible/not part of the form UI
The use case for this is that I have some meta data associated with a form that has nothing to do with the UI, but nevertheless needs to get POST as part of the form submission.
Will this information always be the same? You just want it recorded as part of the entry? Or do you have other plans for it?
The hidden values will be dynamic. Some will be set via query string sent to the form. Others might be client specific, like say timezone, browser type, IP, etc.
None of these would be part of the form UI, but we would want it recorded as part of the form entry in the DB.
In that case, you can add the field to the form and set the Visibility of the field to "Admin Only" which will keep it hidden on the front end, but will record the information in the back end.
Screenshot: http://minus.com/mKEwiiyRQ/
You could also just hide the field using a CSS class. I add hidden to the CSS class of the fields I don't want to show up to the users. Then in my style.css I add
.hidden { display:none; }
Ah, those solutions are perfect! Thanks.