Auto Select Only Option In Lookup

Est. Reading: 1 minute
By: Constantech
Created: 07/13/2017
Category:
Difficulty: Beginner

Auto Select Only Option In Lookup

×Warning: This tutorial was created 2690 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.

This will only work if the lookup field is of type Single Line Text.

Either, or both the created fields, can be set to visibility "Administrator" so as to not be seen by your end user.

Create an ordinary Single Line Text field, and select "Dynamically retrieve the value from a Lookup field".  If need be, watch a lookup field.  There must be only one option retrieved for this to work (pretty obvious, but hey, thought I'd mention it anyways).

Create a Lookup field, and make it of type Single Line Text.  You can have it lookup the same field as your Single Text field is, or not doing a lookup, it doesn't matter either way.

Place the following piece of code in Settings=>Customize HTML=>Before Fields:

<script>
jQuery(document).ready(function($){
$('#field_SLT').change(function(){
var sourceField = $('#field_SLT').val();
$('#field_LSLT').val(sourceField);
$('#field_LSLT').trigger({ type:'change', originalEvent:'custom' });
});
});
</script>

Replace SLT with the field key of your Single Line Text field, and LSLT with the field key of your Lookup field.

And presto bingo, only option in the lookup field is auto selected.

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