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.

gform_field_value_$parameter_name With Multi-Select?

  1. I've seen some tutorials on getting form fields to be populated dynamically and for some reason I can't get it to work with my form. Here's the code I'm using:

    add_filter("gform_field_value_all_industries", "populate_industries");
    function populate_industries($value){
    	$output[]="Value One";
    	$output[]="Value Two";
    	return $output;
    }

    I've checked and my multi-select does have "Allow field to be populated dynamically" checked and the variable name is "all_industries".

    What am I missing?

    /edit: This is in my functions.php and I've tested using var_dump and the hook is firing - it's just not populating the form field...

    Posted 12 years ago on Friday August 3, 2012 | Permalink
  2. For reference so I don't lose this page again:
    http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name

    When troubleshooting dynamic population issues, I like to dump the value of the $form object after submission to see how it's been populated normally, then match my function to populate it in the same manner. Can you create the multi-select normally with a couple values in it, then test the form submission, and dump the $form object to see what things look like? Maybe there will be a clue there that will point to the correct way to pull this off. Thank you.

    Posted 12 years ago on Monday August 6, 2012 | Permalink
  3. Sorry - do you want me dumping the $form object after the custom filter above fires? Or at some other point?

    Thanks,

    --eric

    Posted 12 years ago on Monday August 6, 2012 | Permalink
  4. Hi Eric.

    As a troubleshooting step, I would dump the $form object, just to look at the format of the data stored therein. I can never remember the exact syntax for all the fields, so sometimes dumping the $form object points me in the right direction.

    I would not use your custom filter at all for this test. I would duplicate the form, populate your multi-select in the form builder with some easily searchable/identifiable data (so you can quickly scan the dumped form object), and then when you see how the form builder stores the data for that type of form, you can try to create the data in the same format in your pre-population function.

    Does that make sense? It's not a solution, it's a troubleshooting step to try and figure out if we're doing something wrong.

    Posted 12 years ago on Tuesday August 7, 2012 | Permalink