Skip Navigation

[Resolved] how to conditionally show cred fields based on generic checkbox?

This support ticket is created 6 years, 2 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.

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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Amin 6 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#1150854
availability-1030x725.png

I want to show a group of fields (start time / end time) based on a checkbox ("are you open").

How can I do this in CRED if the checkbox is a generic field?

This would function similar to the image attached.

Thanks in advance.

#1151124

Hi Amin,

Thank you for contacting us and I'll be happy to assist.

To add a generic field for each day of the week (for example "Monday"), you can use the shortcode "cred_generic_field" like this:


[cred_generic_field type='checkbox' field='mon-open']
{
"required":0,
"default":"1",
"label":"Monday Open? "
}
[/cred_generic_field]

To make sure that the related start and end time fields are only shown when this generic field for the Monday is checked, you can use it with the conditional shortcode "cred_show_group" like this:


[cred_show_group if="( !($(mon-open) ne '1') )"]

// code for the Monday's start and end time fields

[/cred_show_group]

Same steps can be repeated for each day of the week, as needed.

Note: To convert your checkbox fields into on/off or toggle switches, as shown in the screenshot, you'll need to add custom script, as this is not a built-in feature.

Following article lists some useful script libraries for that:
hidden link

I hope this helps and let me know how it goes.

regards,
Waqar

#1151408

My issue is resolved now. Thank you!