Skip Navigation

[Resolved] CPT selection list with no reconstruction

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 11 replies, has 2 voices.

Last updated by Minesh 8 months, 4 weeks ago.

Assisted by: Minesh.

Author
Posts
#2684465

Hi !

I have a CPT for "Products" with a few custom fields.
I have a CPT for "Countries" with a few custom fields.

I have a relationship 'many to many' between a Product and a Country

When I add a product in the front-end I have the list of the countries in my product form. When I choose a country it's searching and rebuilding the complete list. Is it possible to have it display as a selection list but like it was a "normal" selection custom field.

The country list is a CPT because it has to be in relation to many other CPT's but it's too slow to rebuild the list.

How to do that if it's possible ?

#2684582

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to know are you using post form or post-relatioinship form?

If you can share screenshot from admin of your form then I will check and see if I can give you any workaround if exists.

#2685245

Hi Minesh

To avoid duplicate data here and there I work a lot with the relationships.
For this example: 1st-genre, 2nd-genre, 3rd-genre, original-aspect-ratio and original-picture-format are related to CPT's: "Genres", "Original Aspect Ratio", and "Original Picture Format". They are lists that will or not change or very not often.

I'd like to be able to display the as quick as it was a dropdown list in the form. Do you have a solution ?

#2685256

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you are using post relationship form and if you want to set parent or child explicitly based on the parent or child information you have - you can set this but otherwise there is no such option to change the select2 to normal dropdown on post relationship form.

Please check the following doc for for possible acceptable attributes for shortcode "cred-relationship-role":
- https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred-relationship-role

#2685271

Is it not a solution to display the options as they are and not like a dynamic search (which is searching and take time) ?

#2685280

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As shared - if you are using many to many post relationship form where you want to display simple drop-down, no, I'm afraid - there is no such option.

#2685290

It's always One to Many. The same then ?

#2685293

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you have one to many post relationship, when if you edit your form with "Expert Mode" enabled and to your relationship field add the following attribute to your parent field shortcode:

use_select2="never"

For example:

	[cred_field field='@film-actor.parent' class='form-control' output='bootstrap' use_select2="never" select_text='--- not set ---' required='false']

Does that helps?

#2685355

It's exactly what I was looking for !!
Thanks a lot !

By the way, is there a way to display the option in an alphabetical order ?

#2685417

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

We do have order and ordering feature:
- https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field

But I'm afraid that it will work only when you use the select2. The order and ordering attribute will not supported when use add the attribute: use_select2="never"

use_select2 Optional. Used in parent select fields. Options are always and never. It will render the parent select field as a Select2 field or not, depending on the value set.

Works only on sites not using the new post relationships (legacy code). If used with new post relationships (Types 3,0+), it breaks the "order", "ordering" and "author" attributes. It can also break background checks like what post type to display in the select field for relationships. Warning: Do not use this attribute if not explicitly required.

#2685430

Hello,
When you say "Warning: Do not use this attribute if not explicitly required." what does that mean exactly ?
Is there a security issue ? Any risk ?

#2685434

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No - no other risks using it. Just you have to compromise with the ordering as it will not respected or work when you use attribute:
- use_select2="never"