Filtering lookup values

By: Abso Woot | Asked: 10/13/2022
ForumsCategory: General questionsFiltering lookup values
Abso Woot asked 2 years ago
According to this article we can filter the lookup field options by using the frm_order_lookup_options filter, however, this filter changes both the option and option value, thus making the lookup field no longer work. I assume this is a bug?
Bobby Clapp replied 2 years ago

I wouldn't call it a bug per se, but yeah I wouldn't desire it to change the saved value either. Did you submit the issue to Formidable Forms support?

Josh C replied 2 years ago

<p>Based on the documentation, this is not the desired functionality so perhaps oversight is a more appropriate word.</p><p>Unfortunately, I am unable to submit the issue to support because the website I am on has a grandfathered formidable license and no one knows the login credentials (the website was built by an agency many years ago).</p>

1 Answers
Victor Font answered 2 years ago

This is the line of code in Formidable Pro's FrmProLookupFieldsController.php file where the filter is applied:

$final_values = apply_filters( 'frm_order_lookup_options', $final_values, $order );

In a lookup field, the options and values are always the same. This is by design. Lookup fields do not support separate values.

If you want to use separate options and values, create a standard dropdown and populate it with the values from the lookup field and use any label you want. In this case, you need to create a callback that is applied to both the frm_setup_new_fields_vars and frm_setup_edit_fields_vars hooks.

Abso Woot replied 2 years ago

If that's the case then the frm_filtered_lookup_options documentation should be updated as it would only be useful to remove options.

Switching to a standard dropdown field defeats the purpose of utilizing the lookup field as then you wouldn't be able to use the "Watch Lookup Fields" feature. A dynamic field might be the way to go as that seems to offer the standard field implementation it forces me to pass the entry to a new page/form.

Victor Font replied 2 years ago

Updating documentation is a question for Strategy 11. This is a community forum where questions are answered by volunteers that have no affiliation with Strategy 11.

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