Skip Navigation

[Resolved] Custom Field Checkboxes Stripping HTML Link

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

Problem:
Custom Field Checkboxes Stripping HTML Link

Solution:
By default, Types sanitize field label for the custom checkboxes field options.

To allow custom HTML in checkboxes field option, you should try to add the following code to your current theme's functions.php file:

add_filter( 'types_sanitize_field_labels', '__return_false' );

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/custom-field-checkboxes-stripping-html-link/#post-1942069

Relevant Documentation:

This support ticket is created 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 10 replies, has 2 voices.

Last updated by Jason Bajor 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1936803

Good morning,

I'm utilizing the checkbox custom field to store a value that contains a link. On the front-end, I want the stored value name to act as a link to a specific URL, however the HTML is not saving/storing in the custom field.

I came across this support topic which is nearly identical to my problem:
https://toolset.com/forums/topic/not-saving-checkboxes-with-href-link/

So, I did as instructed and placed the HTML in the "Selected" field, however the HTML is being stripped out when I save the field. No matter what I do, I cannot get the HTML to save in the checkbox settings. How can I work around this?

Thank you,
Jason

#1938049

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I'm not sure why you want to add the HTML anchor tag within the selected value option.

You can display the checkboxes options on frontend based on checked and unchecked values.

For example:

[types field='field-slug' option='0' state='checked']   
add value to display when checkbox 0 option is checked  
[/types]
 
[types field='field-slug' option='0' state='unchecked'] 
add value to display when checkbox 0 option is unchecked
[/types]
  
[types field='field-slug' option='1' state='checked' ]
add value to display when check box 1 option is checked  
[/types]
 
[types field='field-slug' option='1' state='unchecked']
add value to display when checkbox 1 option is unchecked
[/types]

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

#1938419

Hi Minesh,

I'm not sure I understand your response. Perhaps I was unclear in my support request. I know how to display the checkbox options on the front end, but I want the checkbox option to display as linked text. In other words, I want the displayed value of the option to link to a specific URL.

The previous support thread that I included in my request explains how to do this...however it no longer works. The HTML I am adding to the value is getting stripped out. How can the HTML within a value be retained?

Thank you,
Jason

#1939481

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I just wanted to double check - you want to have checkbox type custom field or checkboxes type custom field?

Maybe you can share screenshot of your field and how you configured.

#1940253
toolset-screencap-3.png
toolset-screencap-2.png
toolset-screencap-1.png

Hi Minesh,

I'm trying to configure checkboxes. It's for a website featuring local land trusts. Each land trust has targeted areas of operation. These targeted areas, or Towns, can be sorted on the front end. But, each individual land trust page shows all of the areas of operation in a list (see attached screencap-3.png). I'd like for each of these areas of operation to act as a link, to a URL I specify in the custom field settings.

Hope this helps.

Thanks,
Jason

#1940609

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I can see that with the current version of Types the HTML link does not get saved with checkboxes option label or selected box.

I've reported this issue for further investigation and escalate it to our next level support.

However - I still do not think that this is a good idea to save the link to checkboxes option selected box.

If you can share details about what link you want to display with what checkbox option and send me admin access details, let me see if I can able to offer you any workaround.

Can you please share all the following required detaials:
- Where I can see the checkboxes field, whats its name
- What link you want to assign to what checkboxes option
- where you are trying to display the link of selected checkboxes, on what page/post?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1941897

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When you try to add the "Areas of Operation" field using the "Fields and Views" button (you can see "Fields and Views" button with the following edit page, You will see the option "Custom values for selected and not selected items" as you can see with the following screenshot: hidden link
=> hidden link

You should add the selected value with your desired URLs and then copy/past the generated code to your Beaver Builder text module.

I've done that for the "Andover" as you can see with your beaver builder:
=> hidden link

#1942069

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Just to let you know that I've added the following line of code to your current theme's functions.php file:

add_filter( 'types_sanitize_field_labels', '__return_false' );

Can you please check also that you are able to add the html link to checkboxes field label and selected box when you edit your custom field group "Land Trust Fields".

#1943179

Hi Minesh, thank you for all of your efforts. I'm good now, the suggestions you made and the filter added to the functions.php file did the trick. I can now do what I need to do.

THANK YOU!
Jason

#1943207

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Great - good to know and thank you for confirmation that now you have the solution that help you to resolve your issue.

Please feel free to mark this ticket resolved 🙂

#1950549

My issue is resolved now. Thank you!