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.

DB lookups for selects and radio button options

  1. OK, I have slugged through a lot of stuff to get GF working for me. And I've been able to so far. What I, and seemingly others really need is a working example (not one line code snippets like in the GF dox) of how to do this. I can hack some code here and there, but I've never written code to interface with a database and populate the arrays. I have written a piss poor outline of what I am trying to do here. Can anyone flesh this out for me and the rest of the GF community? And explain where it goes and how to use it REAL WORLD?

    add_filter('gform_pre_render_51', 'populate_familyIDs');
    
    define function populate_familyIDs {
    
    foreach($form['fields'] as &$field){ 
    
    if($field['type'] != 'radio' || strpos($field['FamilyIDclass'], 'populate_familyIDs') === false)
    	    continue;
    if($field['type'] != 'select' || strpos($field['FamilyIDclass'], 'populate_familyIDs') === false)
    	    continue;
    }
    
    global $wpdb;
    $arrayforradiochoices = $wpdb->get_results("SELECT ALL(field_number=29) as IDs FROM wp_rg_lead_detail WHERE form_id=4 AND field_number=28 );
        return $arrayforradiochoices;
        return $arrayforselectchoices;
    
    } // end populate_familyIDs
    
    And then some code to populate the radio or select choices.

    I hope this gives an idea of what we are trying to do.
    I know there are many on here that will at the very least, give you our sincere gratitude.
    If you require more, let us know.

    I am sure many have done this.

    Thank You for considering helping us out.

    Posted 6 years ago on Wednesday April 10, 2013 | Permalink