This support ticket is created 6 years, 5 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.
How can I collapse/un-collapse a parent/child taxonomy?
My CRED form is overwhelming with every parent/child item displayed and I want to use a bootstrap accordion.
Also, is there a way to have the parent selected when a child of that parent is selected?
Yes a hierarchical taxonomy.
Attached is only a portion of the taxonomy. As you can see this is a long list. I'd like collapse the children so that the list is less daunting. Make sense?
It is not possible to modify the markup output by the cred_field shortcode, so you'll need to use JavaScript and produce a bespoke solution that works with the generated markup.
I have worked out a possible solution for you below, but please bear in mind that providing custom code is outside of our support policy and if you need help expanding on the solution you would need to consult a developer.
You'll need to add a class "accordionize" to the form group for the taxonomy fields where you want this to work.
Here you can see I added it to my status taxonomy:
( function( $ ) {
$( document ).ready( function(){
// first hide the children
$("[class*='tax-children-']").hide();
// now add a change event handler to the parent inputs
$(".accordionize ul.wpt-form-set-checkboxes > li.checkbox input").change( function(){
// parent changed, toggle its children
$(this).parent().parent().next("[class*='tax-children-']").toggle();
});
});
})( jQuery );
Because the toggle is handled by the state of the parent checkbox itself, then the parent will always be checked if a child term is checked.