Skip Navigation

[Resolved] when select category i want automatic change field based on my conditional set

This support ticket is created 5 years, 10 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Author
Posts
#1196425

Hello I need to understand how to set the categories with logical condition, I tried and I almost succeeded. I followed your video tutorial. But when I try to insert a post from the frontend, if I change the category, do not load the fields that I have customized.

To give you an example, I need that when I'm in the form to insert the post from the frontend, in the beginning you select the category and based on the selected category load the custom fields that I have set. In real time. Similar to how your demo filters work

https://toolset.com/reference-site/toolset-real-estate/

I bought your plugin because you told me in the media that it is possible but for now I have not succeeded

#1196500

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2019-02-06 at 07.35.51.png

You have a front-end form to publish a post, and the form includes a category selector. You want certain custom fields to be shown depending on what category is chosen.

This is described on this page of documentation: https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/

I just noticed on that page the screenshot is out-of-date, there is no a separate button to insert the conditional group shortcodes (see my screenshot).

If you are following the documentation and have problems getting it to work, let me know.

#1196561

hello thank you for the answer, the video was useful for me to understand how to solve.

If I can I want to ask you another couple of things. I'm building a general classifieds site, that is, it has all the categories to sell used items.

First of all I want to know if the taxonomy "category" I can make sure that there is not a pre-selected category when I start to insert a new post from the frontend, but I'd like to have the box written "- select -" and that it is mandatory then select a category

What I need to understand then is:

1. How do I enter the locations that can be selected from the post entry form?
2. Can I create locations based on multiple levels? eg region -> province -> city? And can I make sure they are on logical condition? that is, if I select a region, only the provinces of that selected region are loaded and the same thing for the cities after clicking the province

#1196568

however I'm sorry, but I tried to follow the video, but it does not work with the categories.

In the video tells me how to use the logical condition between custom fields, but I need that the user first select the category and then load the custom fields under it selected.

I tried but it does not work.

In the field "value" you have to enter the id and in this case I put the id of the category and it does not work, I also tried to put the name of the category and it does not even work. Why?

#1196617

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Antonio

Sorry, I had overlooked the fact that the UI currently does not allow you to insert taxonomies for the cred_show_group shortcode, and you need to insert them manually. (We do have an internal ticket to improve this, but it is not complete yet.)

If you are using standard WP categories (rather than a custom taxonomy) then you would enter something like the following:

[cred_show_group if="( $(category) eq 'value' )" mode="fade-slide"]
<p>Show this if condition passed</p>
[/cred_show_group]

The 'value' you need to test depends on whether you are displaying categories as a checkbox or a select dropdown. From your question it sounds like you are displaying it as a dropdown, in which case the value needs to be the category id (not the name, not the slug).

(If you were displaying as checkboxes, you would need to use the category slug.)

That's the main question. I'll follow up again with your other questions.

#1196635

Hello, I use the personalized taxonomies through toolset (not the original wp)

And the selector is with dropdown. So in this case what code do I need to insert to make the fields change according to the selected category?

#1196644

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I don't know what your custom taxonomy is called, but you need to use the slug of the custom taxonomies in place of categories, so if your custom taxonomy had a slug of 'status' for example, you would need

[cred_show_group if="( $(status) eq 'value' )" mode="fade-slide"]
<p>Show this if condition passed</p>
[/cred_show_group]

where 'value' needs replacing with the ID of the taxonomy term you are testing for.

The easiest way to see the term ID is to go to the page that lists your terms, hover over the required term and the edit link (which you can see in the status bar at the bottom of the browser) will include tag_ID, which is the id you require for the value.

#1196646

Ok I understood, but you still have not given me a complete solution. I'll give you some examples:

I create 3 categories
Cars
Properties
Work

I create generic custom fields

e-mail
telephone number
images
price

Then I need to customize the three categories with different custom fields for each one

For the cars category I want that in addition to the generic fields there are also:
Registration year
Kilometres
Color

For the property category I want for example the following custom fields:

Type of property
Size
Bedrooms
Bathrooms

Ok?

When I FROM FRONTEND i click on INSERT NEW POST there will be the form I created. And when I clicks on a category the extra fields of that category will be loaded.

So if they choose to publish a car, in addition to generic fields there will also be
Kilometres
Registration year
Color

But then if you think about it and change the category and select properties then the custom fields will also change and you will load those in the real estate category.

I hope I have been clear. I really appreciate your help but I think you still have not understood 100% what I'm interested in but it's quite simple, impossible that you can not do with toolset

Please see also this short video hidden link

#1196663

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You just need to include all of the fields that might be required on the form, and then wrap the parts that you only want to display when a particular category has been selected in a cred_show_group shortcode as I described in the last answer.

So it would look something like:

// Optional fields for cars
[cred_show_group if="( $(custom-tax) eq '1' )" mode="fade-slide"]

[cred_field field="kilometres"]
[cred_field field="registration-year"]
[cred_field field="color"]

[/cred_show_group]

// Optional fields for property
[cred_show_group if="( $(custom-tax) eq '2' )" mode="fade-slide"]

[cred_field field="type-of-property"]
[cred_field field="size"]
[cred_field field="bedrooms"]
[cred_field field="bathrooms"]

[/cred_show_group]

You can include as many conditional display groups as you need in the same form.

#1196667

Ohh yeahh. Great. Thanks is that what i need 🙂 top top top

#1196668

I can ask another thing?, as regards how to do to set that the "categories" module does not have to show the first category, but I would like it to be defaulted to nothing, with a writing like this "- select category -"

#1196678

My issue is resolved now. Thank you!