Skip Navigation

[Closed] Using Conditionals in Forms

This support ticket is created 3 years, 11 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/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 3 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1889065

Tell us what you are trying to do?

I have a post type with 100 custom fields. I would like the user to be able to select from a taxonomy for the "type," and then depending on the type selected, show only certain custom fields. I was told to use conditionals on the form, but I still cannot get this to work.

Is there any documentation that you are following?

https://toolset.com/course-lesson/conditional-display-for-form-inputs/

Is there a similar example that we can see?

I can demonstrate clearly the functionality I'm expecting by using ACF. But I don't have a live link to that.

What is the link to your site?

hidden link

Thank you!

Dan Williford

#1889303

Hi Dan,

Thank you for contacting us and I'd be happy to assist.

To add a taxonomy based conditional display in the Toolset Form, you can follow these steps:

1. Please add a conditional group in your form and select the option to edit the condition manually:
( screenshot: hidden link )

2. If the taxonomy field is set to the "select or dropdown" type field, you'll compare the condition with the target term's ID.

Suppose that your taxonomy slug is "type" and the ID of the term that you'd like to show this conditional field group for is "10":
( screenshot: hidden link )


( $(type) eq '10' )

3. The only difference in case the taxonomy field is set to the "checkbox" type field would be that you'll use the target term's name/title and not the ID:


( $(type) eq 'Type A' )

Similarly, you can keep adding the conditional field groups for the other taxonomy terms and include the specific custom fields within.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1889921

Hello Waqar,

Thank you so much for your help!

I followed these steps but I still wasn't able to get it to work. For one thing, I can only locate the "slug" for the taxonomy term and not the ID. But using the slug with checkboxes still didn't work--nothing changed after the checkbox was selected.

To put the question differently: What is the best way to do a form that uses a taxonomy selection as the basis for conditional fields?

Thank you!

Dan

#1890469

Thanks for the update.

You can locate the ID of a taxonomy term using these steps:

1. Please go to the taxonomy management page and click the edit link of the desired term.
( example screenshot: hidden link )

2. In the URL of the term edit page, you'll see the term's ID in the parameter "tag_ID".
( example screenshot: hidden link )

> But using the slug with checkboxes still didn't work--nothing changed after the checkbox was selected.

- As mentioned in point 3 of my last reply, in case of a checkboxes type taxonomy field, you'll need to use the target term's name/title ( and not the slug ).

If it still doesn't work, you're welcome to share temporary admin login details, along with the page where this form can be seen.

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

The topic ‘[Closed] Using Conditionals in Forms’ is closed to new replies.