Thanks, Victor - there's certainly plenty going on in that example! So for my scenario, I have used your approach and reshaped your code as follows:
add_filter('frm_setup_new_fields_vars', 'masterminds_populate_city_lookup', 20, 3);
function masterminds_populate_city_lookup( $values, $field, $args ) {
if ( $values['field_key'] == 'city_dropdown' ) {
$lu_results = masterminds_icpfrm_config();
$newoptions = array( 0 => array('label' => 'Select a city:') );
foreach ( $lu_results as $lu_entry ) {
$newoptions[] = array('label' => $city_name>dropdown_label;
}
$values['options'] = $newoptions;
}
return $values;
}
function masterminds_icpfrm_config() {
global $wpdb;
/* create the variables for the formidable tables */
$wpdb_prefix = $wpdb->prefix;
$frm_items_table = $wpdb_prefix . 'frm_items';
$frm_item_metas_table = $wpdb_prefix . 'frm_item_metas';
/* get target field IDs */
$city_id = FrmField::get_id_by_key('city_name');
$dropdown_label = FrmField::get_id_by_key('irclu_dropdown_label');
$display_sequence = FrmField::get_id_by_key('display_sequence');
/* create SQL SELECT
* if you have many configuration fields, you can also use a SQL View
*/
$sql = "SELECT city_name, display_sequence FROM city_entries ORDER BY display_sequence;";
return $wpdb->get_results($sql);
}
I'm unsure about the "irclu_dropdown_label". I can't tell if it can be removed or if it is essential and simply needs renaming.
Am I going in the right direction?
Thanks,
Phil.
That’s the field key for the input to be populated.
Please login or Register to submit your answer
https://formidableforms.com/knowledgebase/frm_order_lookup_options/#kb-basic-example is the closest snippet you'll find. Depending on what you want to do you may have to create your own SQL query.
Thanks Bobby. I looked at that snippet in my discussion with FF support, but they stated:
"You can only use to hook to order in descending /ascending order."
As you say, it would need some customisation.