Skip Navigation

[Resolved] Conditional group with checkboxes custom fields on a user form

This thread is resolved. Here is a description of the problem and solution.

Problem:

Conditional display on custom checkboxes field in Toolset Forms.

Solution:

Please try "eq" Comparison Operators, for example:

https://toolset.com/forums/topic/conditional-group-with-checkboxes-custom-fields-on-a-user-form/#post-1361735

Relevant Documentation:

https://toolset.com/documentation/user-guides/cred-conditional-display-engine/

This support ticket is created 5 years, 1 month 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by mohamed-saadC 5 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1361521
html editor section in the form.png
Custom Field to show if condition is met.png
Custom Field used as condition.png

Tell us what you are trying to do?
I am trying to achieve a conditional group on a user form with checkboxes. I already created a conditional group with a radio field that works perfectly, but there are situations where I need to handle it with checkboxes.

Is there any documentation that you are following?
I followed the documentation on the "Conditional Display for Form Inputs" page (https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/) and on "Advanced Conditional Display for Form Sections" (https://toolset.com/documentation/user-guides/cred-conditional-display-engine/)
On this last page, I see that there's a function named CONTAINS(array,value_mixed), but I don't know how to use it.
In my case, my checkboxes field has the slug "competences-fonctionnelles" with 13 possible answers for the user to chose from (it's possible to chose several boxes to check). The last possible answer is "Autre (à préciser)" with the value to save being "autre". So I thought it could be possible to check if the array associated with the field "competences-fonctionnelles" (if it's an array) contains "autre" and if it does, to show the conditional group.
I suppose I am doing something wrong with the way I am trying to use CONTAINS(array,value_mixed), could you help me understand how to use this function as a condition?

In the form, here is how I tried to achieve it:
<div class="form-group">
<label>Compétences fonctionnelles</label>
[cred_field field='competences-fonctionnelles' force_type='field' class='form-control' output='bootstrap']
</div>

[cred_show_group if="( $(competences-fonctionnelles) CONTAINS('autre','autre') )" mode="fade-slide"]
<div class="form-group">
<label>Autre compétence fonctionnelle</label>
[cred_field field='autre-competence-fonctionnelle' force_type='field' class='form-control' output='bootstrap']
</div>
[/cred_show_group]

What is the link to your site?
hidden link

#1361735

Hello,

Thanks for the details, there isn't "CONTAINS" Comparison Operators, see our document:
https://toolset.com/documentation/user-guides/cred-conditional-display-engine/

In your case, please try "eq" Comparison Operators, for example:

[cred_show_group if="( $(competences-fonctionnelles) eq 'autre' )" mode="fade-slide"]
...
[/cred_show_group]
#1361737

My issue is resolved now. Thank you!