I’d like to consolidate my dynamic population scripts into one.I have several forms looking for the same information, and would like to remove the _{id} from the end of the filters:
add_filter( ‘gform_pre_render’, ‘c2c_get_dynamic_info’ );
add_filter( ‘gform_pre_validation’, ‘c2c_get_dynamic_info’ );
add_filter( ‘gform_admin_pre_render’, ‘c2c_get_dynamic_info’ );
add_filter( ‘gform_pre_submission_filter’, ‘c2c_get_dynamic_info’ );
I tried this:
global $wpdb;
$choices = array();
switch($form->id):
case 6 :
foreach ( $form['fields'] as &$field ):
if( $field->id == 1 ) :
$lines = c2c_get_lines($field);
endif;
endforeach;
break;
endswitch;
But it doesn’t work. It works fine if the switch routine is removed.
Can you please post all your code with no comments? You can use three backticks on a blank line, then your code, then another three backticks on a blank line to preserve code formatting. It will look like this in the form editor (this is an image):