I have a taxonomy with hierarchical setup (Country > .. > .. > City)
Then I have a view displaying posts with a parametric search based on taxonomy.
Each post may have one or several taxonomies, but only children taxonomies.
In the parametric search, I only should see the current taxonomies AND THEIR PARENTS.
But I can only setup the view to display :
- either all taxonomies ;
- either only current taxonomies without their parents.
Thank you.
Hi, there's nothing built into Views that will allow you to restrict taxonomy term filters this way. You can choose one of these two options in Custom Search Settings > Let me choose individual settings manually:
- Show all the options
- Show only available options for each input
Beyond that, the filter inputs can only be manipulated with custom code, and there is no JavaScript API for filters.
In that case in seems the only way I can achieve what I want would be to force the parent and grand-parent categories of the manually checked category to be checked while submitting the cred form. Would this be possible ?
Thank you.
We offer two APIs that might be helpful here.
1. cred_form_validate: https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
This API will allow you to stop the Form submission and display a text error message like "You must select all the parent terms" if necessary.
2. cred_save_data: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
This API will allow you to automatically check those parent terms even if the User did not select them in the Form. It's less work for the end User, but it could also be more confusing when these terms are selected automatically without being added in the Form.
My issue is resolved now. Thank you!