Dynamic population not working
-
Hello,
This plugin is great — thank you!
I have having issues with the dynamic population. I eventually need the drop down in one column to populate with titles from a custom post type. I started with just the base filter code you provided and changed the form id, field id and column label to match what I’ve got. Nothing happened. Has anything changed that you know of that might have made this code no longer functional? My test code is below.
Wondering if you could also give advice on how to adapt this to pull in custom post types? Something along these lines: automatically populate a dropdown with post titles?
Thank you for your time!
add_filter( 'gform_pre_render', 'my_gform_pre_render' ); add_filter( 'gform_pre_validation', 'my_gform_pre_render' ); add_filter( 'gform_admin_pre_render', 'my_gform_pre_render' ); add_filter( 'gform_pre_submission_filter', 'my_gform_pre_render' ); function my_gform_pre_render( $form ) { if ( GFCommon::is_form_editor() || 4 != $form['id'] ) { return $form; } if ( is_array( $form ) || is_object( $form ) ) { foreach ( $form['fields'] as &$field ) { // for all form fields $field_id = $field['id']; if ( 15 != $field_id ) { break; } if ( 'list' == $field->get_input_type() ) { $has_columns = is_array( $field->choices ); if ( $has_columns ) { foreach ( $field->choices as $key => &$choice ) { // for each column $isDropDown = rgar( $choice, 'isDropDown' ); $column = rgars( $field->choices, "{$key}/text" ); if ( $isDropDown && 'Select a Nonprofit' == $column ) { $choices = 'Option 1, Option 2, Option 3'; $choice['isDropDownChoices'] = $choices; } } } } } } return $form; }
The page I need help with: [log in to see the link]
- The topic ‘Dynamic population not working’ is closed to new replies.