[Resolved] Bad display of checkboxes with HTML in the values.
This thread is resolved. Here is a description of the problem and solution.
Problem:
Customer was having troubles trying to add html code to the checkbox title. Solution:
I checked it and the issue was that both title and value fields had html code, I made an example where adding the code only to the title worked as expected, I offered this solution and the customer said it sufficed for him. Relevant Documentation: https://toolset.com/errata/html-in-toolset-custom-field-labels-is-stripped-when-saving-the-fields/
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.
I used this script to add html to the values of my checkboxes to ba able to have icons instead of text:
<?php /** * Deactivate the sanitization of custom field and field option labels, * so that they can contain HTML code. * * Note that this is not recommended for sites that don't explicitly need it. * Disabling sanitization can have undesired security or other ramifications. */ toolset_snippet_security_check() or die( 'Direct access is not allowed' ); // Put the code of your snippet below this comment. add_filter( 'types_sanitize_field_labels', '__return_false' );
However, when I add the checkboxes field in a form, I have code displaying in a unordered list of options.
I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.
Our Debugging Procedures
I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.
- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link
Please, let me know if you need any additional details. Have a nice day.
I tried on another clean installation and I still have the same result :"" class="wpt-form-checkbox form-checkbox checkbox" />" before the image I use instead of text.
This is the title of my option in the checkboxes field:
<img src="/wp-content/uploads/2024/02/kw-violence.svg" style="height:30px;width:30px;">
And the Value to store:
<img src="/wp-content/uploads/2024/02/kw-violence.svg" class="kw-icons">
Actually the issue comes from the value of the field.
When I give a value like "good" then in the front-end form it displays correctly the icon, but on the front-end View it displays of course its value, so "good" instead of the icon.
I'd like to display the corresponding icon, so... the label ? is it possible ?
Please check this sandbox I created to demonstrate the title working with html code: hidden link
Login link to sandbox in case you need to consult or edit something in the sandbox for me to see it: hidden link
Please check the screenshot, the title is displaying an image in the front end similar to what you want to accomplish, and in the value I stored only the image link instead of the full html code.
With regard to the value, is there a specific application for storing the full html, wouldn't it suffice for you to maybe store the icon/image url and then work with the link later in the site?