Skip Navigation

[Resolved] Populate a second SELECT FIELD with info from a first chosen SELECT FIELD.bus

This support ticket is created 7 years 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by celso-jP 7 years ago.

Assisted by: Beda.

Author
Posts
#595223

Tell us what you are trying to do?

I have this CPT called (CONVENIO) and it has a single line field with multiple instances called (PLANOS).
Let's use a English Version example:
There is a CPT called COMPANY and this company works with multiple PLANS for their clients (example: Basic Plan, Gold Plan and VIP Plan).
The client will choose the COMPANY and when losing focus from the SELECT FIELD COMPANY (that brings the title of the CPT with the name of the company), the client will choose one of the PLANS this company offers.
So, diferent COMPANIES will provide different PLANS.
How can I, on a CRED FORM, make a dynamic population of the SELECT FIELD PLANS getting the ID from the SELECT FIELD COMPANY and display only the list of the PLANS that company offers?

I checked the database and COMPANIES are stored on POSTS Table and PLANS are stored on POSTMETA table (same post-id with the ID of the COMPANY and post-meta-key as wpcf-plans (one per row).

Is there any documentation that you are following?

I tried the forum but could not find anything after searching for some hours

Is there a similar example that we can see?

nope.

What is the link to your site?

hidden link

#595303

I am a little confused on your workflow.

In a CRED form you can maximally choose one parent when you create a Child post - this is done with the CRED ShortCode
"[cred_field field='_wpcf_belongs_post-type_id' value='' select_text='--- not set ---' class='form-control' output='bootstrap']"

That Field does not allow to choose other Fields of parent posts.
Basically this is the ONLY field that is somehow editable in a Child Post that addresses a Parent Post.

Hence, you cannot edit or choose other parent post data in a Child Post Form.
The only what you can do is display some parent Post Data:
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/ > Information about Parent Items

Can you elaborate on your workflow in case I misunderstood the needs?

#595782

Hi, Beda.

Well, the main issue is:
I need to populate a second select field after a first select field is changed.

So, is there a way to add a ONCHANGE in the [cred_field] shortcode ?????

example: [cred_field field='xxx' post='client' value='' urlparam='' class='form-control' output='bootstrap' ONCHANGE="Y"]

if not, is there a way to make the ID of a cred_field fixed? Everytime I refresh my form, the ID of a select field changes a final number that is part of the field ID.

Thanks in advance.
Celso Jr

#595907

No, but what you could do, is use the CRED Conditional ShortCodes.

Since Fields allow you to pass values to them (most of them), you can wrap those CRED Fields in CRED Conditionals, which check upon the first field's value, and then, output the second Field, with the custom value you pass.

CRED Conditionals are elaborated here:
https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/

This is the closest you can get to your gaol, without using Custom Code.

#595911

Well, I have been studying about this issue and I decided to use a Jquery function to solve it.

So, thank you for your support and we can close this topic.

Thanks a lot.

Yours
Celso Jr