Skip Navigation

[Résolu] Post relationship field with use_select2=’always’ only has ten results

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 4 années et 11 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 réponses, has 2 voix.

Last updated by davidS-53 Il y a 4 années et 11 mois.

Assisted by: Luo Yang.

Auteur
Publications
#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!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.