Dynamically-populated fields in Gravity Forms for Wordpress - wordpress

I'm trying to include Gravity Forms on my wordpress website. I wanted to use dynamically populated fields and looked up the docs that say:
You can populate a field via the query string by appending the dynamic
population parameter you specified for the field to the end of your
form URL along with your custom value.
http://siteurl.com/form-url/?your_parameter=value
I have made my first field dynamically populated and named the parameter "name".
Unfortunately when I type:
You can populate a field via the query string by appending the dynamic population parameter you specified for the field to the end of your form URL along with your custom value.
http://siteurl.com/form-url/?name=test
I'm getting an error Error, Page not found. Do I need to change something in my permalink section?

You need to enable "All field to be populated dynamically" option for the field that you want to be populated by url parameter. Try using anything other than "name" for example "your_name" or "full_name". It will work properly.

Related

How does Symfony generate the id/name for a form field?

In buildForm() I would like to extract the full id/name of the current form field node. $builder->getName() returns only the name of the current node but I need the full property path, for example:
id="type_employments_0_location"
name="type[employments][0][location]"
Is there any way to generate this while building the form?
I'm working on a custom mandatory field type extension that looks up the "mandatoriness" of each field as the form is built; hence I need the full property path in buildForm() so that I can modify the options array.
From the FormConfigInterface, You should be able to use $builder->getPropertyPath().
It will return a PropertyPathInterface object, just use it as a string to get the real property path as string (i.e. print $builder->getPropertyPath() will give type[employments][0][location]).
Actually, it's pretty easy.
For every field type has many variables assigned.
<label for="{{ form.fieldname.vars.id }}">...</label>
From symfony doc (Form Variables Reference):
variables are common to every field type. Certain field types may have
even more variables and some variables here only really apply to
certain types.
Assuming you have a form variable in your template and you want to
reference the variables on the name field, accessing the variables is
done by using a public vars property on the FormView object.
Form Variables Reference
In a nutshell: The full property path generated by the form framework is not available to buildForm() but is available to buildView() and finishView(). Use those if you need access to the full property path.

Access Gravity Forms fields on previous page (before pre-submit)

Here's the sitch: I'm using a multi-page Gravity Form in conjunction with an external API.
On the first page of the form, the user supplies a phone number. On a subsequent page, I need to send the external API the phone number in order to retrieve the user's current settings, which then must be prepopulated in other fields.
I know how to use gform_post_paging, but since $entry hasn't been created yet I can't use it to pull fields from previous pages.
gform_pre_submission/gform_after_submission don't help me because I need to make the API call prior to users reaching the end of the form.
I've also tried handling this via jQuery, by pulling and storing the value of the phone field on page advancement (e.g. var phoneNum = jQuery('#input_2_25').attr('value');), but I get "undefined" no matter what when using field ids. (It works fine, in the same location, looking for other ids on the site, so the issue isn't with jQuery.) I'm guessing this means that between pages, the form elements don't exist in the view?
How can I accomplish this goal (i.e., retrieving a value from a previous page in a multi-page Gravity Form prior to the user reaching the end of the form)?
All of the data is stored in the $_POST variable on each page submission. Gravity Forms has a helper function for accessing $POST data. The format for the variable name will be 'input{fieldId}'.
$value = rgpost( 'input_1' ); // replace "1" with your field ID

Are there Security Risks with Gravity Fields Dynamic Field Population?

When populating the values of input fields via parameters in a URL (dynamic population) in Gravity Forms, are there any security risks?
You do have to name the fields when editing the form in order for a parameter in the URL to do anything. And all it does is populate the value of an input field. But I wonder if this opens up any vulnerability.
all it does is populate the value of an input field.
That's right, and before the value is sent to the browser it is always escaped by the appropriate WordPress helper function.

Views Module: Display a key from user data (Drupal 7.x-3.11)

I'm having problems wit the User: Data field.
I want to set the Display format to A certain key to output the identifier value from this serialized data (relevant snippet):
a:1:{s:10:"hybridauth";a:26:{s:10:"identifier";s:17:"76561198181833179";
When I enter identifier as key, I only get this notice and no output:
Notice: Undefined index: identifier in
views_handler_field_serialized->render() (line 60 of
/www/htdocs/****/sites/all/modules/views/handlers/views_handler_field_serialized.inc).
What do I have to enter in the "Which key should be displayed"-field exactly, to display the identifier value?
Views Module: Display a certain key from the serialized user data (Drupal 7.x-3.11)
To achieve this you have to alter your view using hook_views_pre_view.
Steps:
Add a uid field and make it hidden in your view.
Add a custom or html field to your views(so that you can alter later).
In hook_views_pre_view and for the above view and above view display write your php logic to load the current user with the uid field in the view.
After loading the user use the data value of the loaded user and unserialize it and replace it with the custom or html field value.
Thanks

Wordpress - Passing Variable to Custom Post Type Archive

I am using /%postname%/ permalinks and want to be able to pass a variable to my custom post type archive. My goal is to have the archive receive a value which I use to sort the individual posts. My overall goal is essentially fake 'categories' by assigning the custom posts a meta value and sorting using the value I pass through the url.
A more literal Example:
example.com/vegetables/
is the path to my custom post type archive. I want to be able to direct users to this path:
example.com/vegetables/potatoes
and in the template be able to pull "potatoes" from the query string.
Any ideas?

Resources