Change Suggest Field Minimum Length

Hello,

I need to lower the suggest field minimum length to 2 or 1 characters instead of 3. I have the field searching through a custom post type, and it works great, but one of my posts has a 2 letter title and I can’t pull it right now. Is this something I can change through the module and if not where would I change it in BB core?

Thanks

Hey Mike,

There is no such setting for that on the module, unfortunately. I’ve assigned another member of our team though to check in on this and see if there’s something that can be done. :slight_smile:

Ben

Hey Mike,

I’ve already filed an enhancement report for this. We’re going to make it so it’s easy to adjust the minimum number of characters required before it starts to search. :slight_smile:

Ben

That is awesome thank you! Could you provide any info on how I could hack this together myself in the meantime?

You bet! For now, you can adjust the minChars variable in js/fl-builder.js on lines 4689 and 5728. I’ll post back with info on how to implement that in a custom field when it’s ready.

Somewhat related – is there any benefit to using jquery-autosuggest instead of select2? With select2 you could allow devs to pass args as data attributes thus eliminating the need to add custom args.

Hey Josh,

I’d need to look into it, but we might also be able to allow you to pass args to autosuggest as well. That’s a great idea and will undoubtably be helpful, so I’ll see what we can do there.

Thanks!
Justin

Hey Josh and Mike,

When 1.7.4 comes out this week, you will be able to pass any number of args for the auto suggest field in the config array like so…

array(
	'type'          => 'suggest',
	'action'        => 'fl_as_users',
	'label'         => __('Authors', 'fl-builder'),
	'args'			=> array(
		'selectionLimit' => 3,
		'minChars'       => 1
	)
)

Let me know if you have any questions about that.

Justin