PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How to use: Allow field to be populated dynamically

  1. I see an option for "Allow field to be populated dynamically" i have a page with an address, I then want to confirm that is the mailing address on the next page. So I want to dynamically fill the forms.

    So when I click "Allow field to be populated dynamically" I see several fields but I dont know how to fill them. What do I put in the Parameter Name? How do I know what it is?

    Posted 13 years ago on Tuesday February 8, 2011 | Permalink
  2. The parameter name is whatever you want it to be. The parameter name is what you use to populate the field dynamically via the query string or via PHP. So for example.

    - I create a form
    - I add an Email field to the form
    - I edit the Email field and select the Advanced tab
    - I give the Email field a parameter name of email
    - I save the form

    Now when I load that form, if I pass the email value to it via the query string (ex. http://mydomain.com/mypage?email=email@email.com) it will pre-populate that field. So using the query string method you would pass data to the form as part of the link to the page containing the form.

    You can also pre-populate it using PHP, again using the parameter name, but that is more advanced. What is your skill level with PHP and WordPress development?

    Posted 13 years ago on Tuesday February 8, 2011 | Permalink
  3. jcrsantiago
    Member

    So there is no way to do that in the interface? I can use php, but mainly I insert code not create any.

    Posted 13 years ago on Tuesday February 8, 2011 | Permalink
  4. I'm not sure what you mean by do it in the interface? Dynamically populating the value of a field is done either via the query string or via custom PHP. You have to write the code that dynamically populates the field. I'm not sure how you could populate it without either passing the value in the query string or by writing code? I'm not quite sure I understand what you are trying to accomplish.

    If you want to populate form fields dynamically you need to tell it what the values should be. I don't see how that can be automated. You have to tell it the values, that is how things are populated dynamically by writing code to tell it the values automatically.

    Posted 13 years ago on Tuesday February 8, 2011 | Permalink
  5. Carl, if a user has to be logged in to access a form, is it possible for form fields (specifically POST form fields) to be automatically populated used the user's registration data?

    E.g. I can get the user's email address for an email field through the default value setting, but what I need to do is automatically assign the category for a post based on who is logged in - is this possible?

    Posted 12 years ago on Friday May 13, 2011 | Permalink
  6. Yes, it's possible to get some user information and set them as default values for fields. There is a drop down above the Default Value when editing a field that lets you insert merge codes, some of the merge codes include User related information such as email, etc.

    As for automatically assigning a category based on who is logged in that would have to be done via PHP using available API hooks, it's more advanced. You'd have to use hooks which are documented in the developer docs of the Documentation to do this using PHP. If you aren't familiar with custom PHP and using WordPress hooks you may need to look into having a WordPress developer assist you.

    Posted 12 years ago on Friday May 13, 2011 | Permalink
  7. davidcmadrid
    Member

    WE just moved from contact form 7 to this plugin. In CF7 we used to populate a form field with what it called a "watermark" , you call this "default" value and we had to go to " custom field " to do so . The one problem from a users perspective is that when i click the field for example to enter my name , its that the autopopulated content does not dissapear. CF7 calls this watermark. Is there a way to have the auto content in the field dissapear upon mouseclick like CF7 ? Otherwise great plugin.

    Posted 12 years ago on Thursday June 30, 2011 | Permalink
  8. @davidcmadrid The default value is not the same thing as CF7's "watermark". A default value is a default value, it is a valid value. What you are referring to is a placeholder. We have been holding off on implementing placeholder functionality until the HTML5 placeholder attribute is more widely supported by browsers because we did not have to implement it using javascript, however it is a feature we will probably end up implementing anyway as HTML5 support is lagging.

    It can be done now, but as a customization using jQuery. Here is a tutorial that discusses how to do this:

    http://www.gravityhelp.com/clearing-default-form-field-values-with-jquery/

    Posted 12 years ago on Thursday June 30, 2011 | Permalink
  9. kennethjaysone
    Member

    Carl, ok, so i have a form that only allows logged in users to submit data. Now i want to populate the name (first and last). So in the form editor:

    1) Under the advanced tab, i click on "Allow field to be populated dynamically"

    Under field parameter name, there is 2 inputs

    first:

    last:

    So i have to give a name e.g. first_name and last_name (these would be the names of the parameters)

    After doing this (now i'm publishing my form on a page), i'll have to put in this shortcode:

    [gravityform id="2" name="Make a purchase!" field_values='first_name=val&last_name2=val']

    Is that correct? first_name=val? and last_name=val?

    should val be something else or this is sufficient?

    Posted 12 years ago on Monday November 21, 2011 | Permalink
  10. "val" would be the value you want to set it to. Your example uses a shortcode to dynamically populate those fields. What you are trying to do you would likely not be using the shortcode method to populate those fields because you don't know what the values are. You use the shortcode method to dynamically populate the field values when it's something post or page specific.

    If you want to populate the name field using the logged in user's information you would need to use the PHP method to dynamically populate the field. You would use the parameter names that are setup, however you'd have to write PHP to populate them with the name of the logged in user.

    Here is a tutorial on how to use hooks to dynamically populate a field:

    http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population#Hooks

    Posted 12 years ago on Monday November 21, 2011 | Permalink