Okay
  Public Ticket #1353636
populate dynamic dropdown fields from mysql column
Closed

Comments

  • Paulo Lopes started the conversation

    Hello, my formidable pro form has one dynamic dropdown to be populated dynamically from one of the columns of my mysql database. How do I populate formidable dynamic dropdown using your integration?

  •  471
    Isidora replied

    Hi Paulo,
    Thank you for your purchase.

    Sorry but I did not quite understand what are you trying to achieve. Can you please explain me more and send me some example/screenshot so I can give you my suggestion.

    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables

  • Paulo Lopes replied

    Hi Milan, thanks for the prompt reply.

    I try to say that my formidable pro form has a dynamic drop-down field that is populated from an extra custom table inside the $wpdb. In order to do this so I use a hook into the Code Snippet plugin. Where can I enter this hook in your application to achieve this feature?

    DB example:

    wpdb/wp_table1

              /wp_table2

              /wp_my-custom-table-to-feed-drop-down         

    ============ the hook is something similar to this where my table is pp_teachers and dropdown field ID is #100-----------

    add_filter(frm_setup_new_fields_vars, frm_populate_member, 20, 2);
    // add_filter(frm_setup_edit_fields_vars, frm_populate_member, 20, 2); //use this function on edit too
     
    function frm_populate_member($values, $field){
        if($field->id == 100 || $field->id == 733){ //replace 732 and 733 with the IDs of the fields to populate
            global $wpdb;
            //the Query
            $the_Result = $wpdb->get_results( "SELECT concat_ws(', ', last_name, first_name) as display_name FROM wp_database.pp_teachers where account_state = 'active' order by last_name, first_name;" );
     
            unset($values['options']); //break the binding of any existing content in the values array
     
            $values['options'] = array(); //remove this line if you are using a checkbox or radio button field
            $values['options'][]="";
     
            //the Loop
            if(! empty($the_Result)){
                foreach($the_Result as $a_user){
                    $values['options'][]=$a_user->display_name;
                    $values['use_key'] = false;
                }
            }
        //$values['use_key'] = true; //this will set the field to save the post ID instead of post title
        }
    return $values;
    }

    ====================================================


    Thank you.

    Paulo

  • Paulo Lopes replied

    Hello Milan, my question is more related to Formidable support, not you.

    I so sorry,

    Paulo

  •  471
    Isidora replied

    Hi Paulo,

    It's no problem.

    If you have any more issues feel free to open a new ticket, we will gladly help.

    We'd greatly appreciate it if you could take a minute and leave a review on CodeCanyon on this link. Thanks! 

    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables