Skip Navigation

[Resolved] Changing the output of checkboxes

This support ticket is created 2 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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by katinaA 2 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2289115

We are trying to change the output from a checkboxes custom field from the data associated with the selected option to display a specific image instead.

Our field is called Partner Awards. It has two checkbox options, 2021 Award Recipient and 2022 Award Recipient. We want each option to have its own image. So if 2021 Award Recipient is checked, then this field will output the image for 2021. If 2022 Award Recipient is checked, then this field will output the image for 2022. If both options are checked then the output should show both images.

A page where you can see our attempt to do this is at the bottom here:

hidden link

The content template is located here:

hidden link

We want this field set up to conditionally display if it is not empty. That way nothing will display if neither of the options are checked. I set up a conditional the way you showed me to do it working for another client, but it's not working. If you view the page here,

hidden link

you can see Partner Awards: showing with nothing listed below it. That header would not display at all if the conditional was working. So I did something wrong there too. Let me know if I need to separate these into two different support threads.

#2289473

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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

To troubleshoot this, I'll need to see how this content template and the conditional display are set up in the admin area.

Can you please share temporary admin login details, in reply to this message?

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2292471

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

During troubleshooting, I noticed that the conditional check was evaluating for an empty value:


[wpv-conditional if="($(wpcf-partner-awards) ne '')"]
....
[/wpv-conditional]

But the 'Partner Awards' is set to save '0' when unchecked, in the field's settings, so this field output will not be empty. To fix this, I've changed the condition to check for the value '0' instead:


[wpv-conditional if="($(wpcf-partner-awards) ne '0')"]
....
[/wpv-conditional]

As a result, the heading doesn't display, when none of the checkboxes are checked.

To show the image for each option, you can use the Types fields shortcode for the checkboxes type field, like this:
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes )


[types field='partner-awards' state="checked" option="0"]<img src='Image URL for 2021 image'>[/types]
[types field='partner-awards' state="checked" option="1"]<img src='Image URL for 2022 image'>[/types]

Note: You'll replace 'Image URL for 2021 image' and 'Image URL for 2022 image', with the actual links for the images.

I hope this helps and please let me know if you need any further assistance around this.

#2293385

PERFECT!!! You guys are awesome! Best support I've ever seen from a plugin/theme team. Thanks so much!

#2293387

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.