[Resolved] With Toolset Form, display conditional group depending on category checked
This support ticket is created 4 years, 6 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
1) I create a form to publish a new Post. On that form, user can choose categories.
2) Once the post is published, the user can edit it with another form and add information.
3) My problem is: I want to display some custom fields depending on categories checked during Step 1). -> If category ID #1 OR #2 checked then display custom fields.
I tried this: [cred_show_group if="($(category) eq '16' )" mode="fade-slide"][/cred_show_group]
Hello. Thank you for contacting the Toolset support.
Can you please share the problem URL where I can see the form as well as access details. In addition to that, please mention which field you want to display conditionally.
*** 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.
Unfortunately the project is local right now, I cannot share access.
But it's a very generic problem.
Category is the built-in taxonomy of WordPress.
It could be:
- if category checked of the current post has ID #123, then display the CRED group,
OR
- if category checked of the current post has slug 'xyz', then display the CRED group.
I just don't know what to write to specify to check the ID or the slug of the category...
I'm sorry it's not working. Also on your example "Top Performer" is not a slug and not an ID. Probably a title. I don't want to use the title...
[credform]
[cred_field field='form_messages' class='alert alert-warning']
[cred_show_group if="($(category) eq '16' )" mode="fade-slide"]Must be displayed if category ID #16 was selected when post was published.[/cred_show_group]
[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/credform]
Reminder: it's a form to edit, so the category was already selected and saved when the post was first published.
I just would like to have a little additional details. How you displaying the category taxonomy with your form. Is it as checkboxes or dropdown select?
I don't understand why it matters. Category taxonomy is not displayed on this form.
1) User creates a new custom post with CRED Form where he chooses one or more categories.
2) User edits the custom post previously created with another CRED form. -> Categories already has been selected on a previous form. I did that because I thought it was necessary to already have that information saved.
It seems you are not getting me what I am asking.
1) User creates a new custom post with CRED Form where he chooses one or more categories.
- OK. How you are displaying the category on this form? as a dropdown select or list of checkboxes? Why I was asking for this because there are two ways you can display taxonomy field with Toolset form. Either checkboxes or dropdown select.
The category taxonomy field should be added to the form (in your case the category field) and with the previous reply you shared, I do not see you have added the category field to your form.
If you just want to display:
[cred_show_group if="($(category) eq '16' )" mode="fade-slide"]
Must be displayed if category ID #16 was selected when post was published.
[/cred_show_group]
Then, what if you try to change your conditional statement as given under:
[wpv-conditional if="( CONTAINS(#(category),'16') )"]
Must be displayed if category ID #16 was selected when post was published.
[/wpv-conditional]
I'll try to fix a misunderstanding going on still the begin of this thread.
User uses Form ABC to create a new custom post, at this step, he chooses categories (WordPress built-in categories).
Then, using other forms, he edits the custom post to add relevant information.
On these other forms, I would like to display conditional groups depending on information the system already has.
I don't want they edit the categories, I don't want they choose new categories. I just would like to display the right fields.
On the form we're concerned here, categories is only an information already registered/saved which is the condition only.
When I create a new conditional group using the GUI, I've choices like "post title", "post excerpt", "featured image" and other custom fields I created with Toolset.
Question is only: how do I use the category of the post as condition?