Home › Toolset Professional Support › [Resolved] Edit Form – cred_show_group not working for multiple categories
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.
Our next available supporter will start replying to tickets in about 1.85 hours from now. Thank you for your understanding.
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)
Tagged: Content-submission forms, Toolset Forms
Related documentation:
This topic contains 31 replies, has 3 voices.
Last updated by Minesh 3 years, 3 months ago.
Assisted by: Minesh.
Hi,
I have a front-end Edit form and I'm trying to use a conditional group to show/hide some checkboxes fields if the Spa category is selected from a custom taxonomy “listing-category”. This works if this only the parent Spa category is selected like:
[cred_show_group if="($(listing-category) eq '313')" mode='fade-slide']
But I want these fields to show if the parent is chosen and also if a sub-category of the Spa is selected, however if a sub-category is chosen it does not appear. So for example this code does not work
[cred_show_group if="($(listing-category) eq '313') OR ($(listing-category) eq ’314’) OR ($(listing-category) eq '315') OR ($(listing-category) eq '316’) OR ($(listing-category) eq '317’) OR ($(listing-category) eq '318') " mode='fade-slide']
I've also tried using an array:
[cred_show_group if="($(listing-category) eq ARRAY('313','314','315','316', '317', '318') )" mode='fade-slide']
Also, if the Spa category is deselected from from the Edit form, and then re-selected, the checkbox selections within that hidden area get cleared out, the data is lost. This can’t be the normal behavior is it?
Thanks,
Tim
Hello. Thank you for contacting the Toolset support.
Can you please try to use the term name instead of term ID with your conditional statement.
I checked the conditional group as given under:
[cred_show_group if="( $(product_cat) eq 'Clothing' ) AND ( $(product_cat) eq 'Accessories' ) AND ( $(product_cat) eq 'Tshirts' )" mode="fade-slide"] <div class="form-group"> <label>WooCommerce Product Price</label> [cred_field field='views_woo_price' force_type='field' class='form-control' output='bootstrap'] </div> [/cred_show_group]
- As you can see I've used the term name instead of Term IDs and its working for me.
You should try to adjust your conditional statement as above and check if that help you to resolve your issue.
That doesn't seem to work. It seems to work only if one individual category is used in the show_group but if multiple ones with OR statements then it's not working.
With my local test site I can see its working even with the OR conditional statement added using the [cred_show_group].
Can you please share problem URL and access details so I can check the issue and see what I'm missing with my test case or correct your code if its not correctly written.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I need to check with my local test install now. I was checking with the checkboxes field but actually you have added your taxonomy field as a multiple select field.
I will get back to you as soon as I know more.
Sorry, those custom fields you see under the Spa and Massage are old custom fields (that match the taxonomy names), they are not used, the taxonomy is actually set above that in the "Listing Categories" taxonomy field.
Upps.. its confusing.
Can you please tell me, I'm adding a conditional statement using the listing-category field. Now, can you please tell me what field you want to show hide?
Sorry, hope this clarifies:
hidden link
Do you need more clarification from me?
I ran out of the time today, I will try to run a test by adding the same taxonomy as select and try to display conditional output and will get back to you with updates by tomorrow.
Ok - I've checked with my local test install where I've added the product category taxonomy as multiple select and added the following code to the form to conditionally display the field:
[cred_show_group if="( $(product_cat) eq '25' ) OR ( $(product_cat) eq '26' ) OR ( $(product_cat) eq '27' ) OR ( $(product_cat) eq '28' )" mode="fade-slide"] <div class="form-group"> <label>WooCommerce Product Price</label> [cred_field field='views_woo_price' force_type='field' class='form-control' output='bootstrap'] </div>[/cred_show_group]
I can see it works as expected.
In order to minimize the cause of the issue on your install:
1) Can you please disable cache
2) Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes? - Do you see any difference?
3) Can you please try to create another test edit form where you should display only 2-3 fields and try to add the conditional statement and check if that helps.
If none of the above steps helps - I will require a duplicator copy of your install in order to troubleshoot your issue further.
=> https://toolset.com/faq/provide-supporters-copy-site/
I have set the next reply to private which means only you and I have access to it.
Sorry I have not had time to do the testing you suggested, I will do it tomorrow and let you know if it works.
Ok fine - please follow the steps and try to isolate the issue if possible to know where exactly the issue is.
Sorry for the delay in response. I finally had the chance to disable cache, disabled all plugins except toolset forms, types, and views, and switched to the default 2020 theme. The issue persists. I created the simplified test edit form so it's now clear there is something wrong with using "OR" because the fields do show if one single Spa category is chosen, but when multiple ones are chose it does not appear.
Form front-end: hidden link
Form Back-End: hidden link
Also the other issue I mentioned previously still occurs, if a non Spa category is selected and the form is saved. Then a Spa category is selected and the for is saved again the fields that were previously saved in those custom fields are gone. It's as if the cred_show_group when it hides then shows clears out checkboxes fields.
Tim
Hello,
Minesh is on vacation, I will take care of this ticket.
I am checking it in your website, and will update here if there is anything found.