Show more than 1 field in a Dynamic Dropdown

Est. Reading: 1 minute
By: morvarghmatt
Created: 02/15/2018
Category:
Difficulty: Intermediate

Show more than 1 field in a Dynamic Dropdown

×Warning: This tutorial was created 2471 days ago. Some of the information may be out of date with more recent versions of Formidable. Please proceed with caution and always perform a backup before adding custom code.

A tip to to show many fields in a Dynamic Dropdown instead of the default one entry to select from.

For example when you are using it to select Surname field and you have multiples of the same surname; this code added to Functions.php or custom plugin allows you to have the dropdown show "Surname, Firstname, Date of birth" to select from...

add_filter('frm_setup_new_fields_vars', 'yourfunctionname', 25, 2);
function yourfunctionname( $values, $field ) {
if ( $field->id == 1031 && !empty( $values['options'] ) ){ //Replace 1031 with the ID of your dynamic field you want to change
$temp_values = $values;

$temp_values2['form_select'] = 320; //change 320 to the id of the second field you want to show in your dynamic field
$temp_values3['form_select'] = 984; //change 30 to the id of the third field you want to show in your dynamic field

$field2_opts = FrmProDynamicFieldsController::get_independent_options( $temp_values2, $field );
$field3_opts = FrmProDynamicFieldsController::get_independent_options( $temp_values3, $field );

foreach ( $values['options'] as $id => $v ) {
$values['options'][ $id ] .= ' '. $field2_opts[ $id ] . ' (' . $field3_opts[ $id ] . ')';
}
}
return $values;
}

Hope it helps others

Regards

Matt

Leave a Reply

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crosschevron-leftchevron-rightarrow-right