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.

Dynamic Population: Problem with multiple "filters"

  1. sidjags
    Member

    Hey there... i'd be very grateful if you could point me in the right direction here:

    i've followed the instructions on how to dynamically populate a field in the form by using a query (in functions.php)... and it works fine... I have this form on a post with certain "custom fields/meta values"... and am populating the form with the same... so, i do it for one of the fields like so...

    [php]
    add_filter('gform_field_value_city', 'populate_city');
    function populate_city($value){
        global $post;
    	$city = get_post_meta($post->ID, "city", true);
        return $city;
    }

    where my parameter name is "city"... and also my custom field name is "city" too... and it works... now i repeat the same thing two more times to get two more custom field values...

    [php]
    add_filter('gform_field_value_country', 'populate_country');
    function populate_city($value){
        global $post;
    	$country = get_post_meta($post->ID, "country", true);
        return $country;
    }
    
    add_filter('gform_field_value_region', 'populate_region');
    function populate_region($value){
        global $post;
    	$region = get_post_meta($post->ID, "region", true);
        return $region;
    }

    so... that's three in all... "city", "country" and "region".... and when i do this... it ives me a blank screen... if i remove two of the three... and leave only one.. anyone... it works... but doesnt work for more than one...

    can you please help me out here...

    Posted 12 years ago on Sunday December 11, 2011 | Permalink
  2. sidjags
    Member

    never mind... there seemed to be a problem with a "typo" or rather wrong name... in one of the lines... this works now:

    [php]
    add_filter('gform_field_value_city', 'populate_city');
    function populate_city($value){
        global $post;
    	$city = get_post_meta($post->ID, "city", true);
        return $city;
    }
    
    add_filter('gform_field_value_country', 'populate_country');
    function populate_country($value){
        global $post;
    	$country = get_post_meta($post->ID, "country", true);
        return $country;
    }
    
    add_filter('gform_field_value_region', 'populate_region');
    function populate_region($value){
        global $post;
    	$region = get_post_meta($post->ID, "region", true);
        return $region;
    }

    all 3 fields get populated the right way... thank you though... and i'll be back if theres something else i get stuck with...

    sid

    Posted 12 years ago on Sunday December 11, 2011 | Permalink
  3. Thank you for the update. And thanks for posting your code. I'm sure it will help someone.

    Please let us know if you need additional assistance.

    Posted 12 years ago on Monday December 12, 2011 | Permalink

This topic has been resolved and has been closed to new replies.