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.
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
My issue is resolved now. Thank you!