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.

Filling gform_field_value with values using post

  1. brad13x
    Member

    I need to be able to access post values from gform_field_value. Is there a way? I have tried $_post and rgpost.

    Posted 8 years ago on Wednesday August 3, 2011 | Permalink
  2. What exactly are you trying to do, populate a field using the value of post related data? If so, here is a tutorial that discusses how to populate a field using the Post Author that may be able to get you started:

    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_the_Post_Author

    Posted 8 years ago on Wednesday August 3, 2011 | Permalink
  3. brad13x
    Member

    Hey again Carl.

    I'm trying to create a form so that when a person enters their customer code the form auto fills their name and address to the form on the next page.

    I'm able to use

    add_filter('gform_validation', 'custom_validation');
    function custom_validation($validation_result)

    to check if I have a valid customer but then I'm unable to use post or a global var to get the customer code to gform_field_value. How can I do that? Also is gform_field_value called before gform_validation?

    Here is the form below.
    http://dev.cheminc.com/order-form/
    Please select I have my customer code and enter "sdaf" (no quotes)

    Posted 8 years ago on Thursday August 4, 2011 | Permalink
  4. brad13x
    Member

    Is it possible get a post value into the function gform_field? Should I try to use a cookie or a global?

    Brad

    Posted 8 years ago on Monday August 8, 2011 | Permalink
  5. No. gform_field_value fires when the form is displayed, at which point nothing has been post because the post doesn't happen until after the form is submitted. So you can't use something that is triggered when the form is displayed to do something the form is submitted.

    You would have to use PHP and jQuery to pre-populate those fields using jQuery using the gform_validation hook to check the field and get the user data based on what is passed and then use jQuery to populate those fields. The gform_page_loaded jQuery hook is documented here:

    http://www.gravityhelp.com/documentation/page/Gform_page_loaded

    So what you are trying to do can't be done with the standard dynamic field population because you want it to happen via gform_validation which isn't the normal way of populating fields dynamically.

    Posted 8 years ago on Monday August 8, 2011 | Permalink
  6. brad13x
    Member

    Can I use something like this? http://pastie.org/1432081 I just need a way to grab and prefill fields based on customer ID. I don't have to use gform_validation.

    Posted 8 years ago on Monday August 8, 2011 | Permalink
  7. brad13x
    Member

    I'm not very good with JS. Can you please send me a more detailed example? Of this http://www.gravityhelp.com/documentation/page/Gform_page_loaded?

    Posted 8 years ago on Monday August 8, 2011 | Permalink