Skip Navigation

[Resolved] Post relationship field with use_select2=’always’ only has ten results

This thread is resolved. Here is a description of the problem and solution.

Problem:

Display more items in the parent select2 search result of Toolset form.

Solution:

You can use Form filter hook cred_select2_ajax_get_potential_relationship_parents_query_limit, for example:

https://toolset.com/forums/topic/post-relationship-field-with-use_select2always-only-has-ten-results/#post-1240194

Relevant Documentation:

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by davidS-53 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1240154

As per the title. I have a dropdown set up like this:

<div class="form-group">
		<label>Crew Member</label>
		[cred_field field='@crew-member-crew-certificate.parent' select_text='--- not set ---' class='form-control' use_select2='always' output='bootstrap' author='$current']
	</div>

To set a relationship between two post types. However, the above code only outputs the first ten possible crew members, not the full ten. They all have the correct author set etc.

Is there a limitation of ten when using select2 or something?

#1240184

Hello,

Please elaborate the question with more details:
only outputs the first ten possible crew members, not the full ten

If you need to display all available options, you can disable select2 feature by changing the codes you mentioned above, from:
use_select2='always'

To:
use_select2='never'

More help:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
use_select2 Optional.
Used in parent select fields. Options are always and never.

#1240193

If I use use_select2='never' another parameter author='$current' stops working- so unfortunately that is not an option.

What more information do you need?

only outputs the first ten possible crew members, not the full ten

Yes. There are 12 crew members who should be in the dropdown, but only the first ten are displayed in the dropdown.

#1240194

By default the parent select2 selector will output only 10 items, you will need to type some keywords and search.

If you want display more items in the select2 search result, you can use Form filter hook cred_select2_ajax_get_potential_parents_query_limit, for example:

add_filter('cred_select2_ajax_get_potential_parents_query_limit', function($limit){
  return 15;
});

Above codes will be able to return 15 items in the select2 search result.

#1240289

Hi Luo, great- I thought there was some kind of limit. I've added that code, but it doesn't appear to do anything unfortunately. Any ideas why that could be?

#1240305

You are right, it is another filter hook "cred_select2_ajax_get_potential_relationship_parents_query_limit", please try to change the PHP codes as below:

add_filter('cred_select2_ajax_get_potential_relationship_parents_query_limit', function($limit){
  return 15;
});

And test again.

#1240362

Perfect, that does the trick exactly. Much appreciated!