Skip Navigation

[Resolved] Apostrophe in Custom Field Content for Radio 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.

This topic contains 5 replies, has 3 voices.

Last updated by Christian Cox 8 months, 1 week ago.

Assigned support staff: Christian Cox.


I've noticed that if I create a Radio field and enter text including an apostrophe in the Custom Field Content box, the value is being escaped when saved to the database and the backslash is then rendered on the frontend. So, for example, text to save to the database set in Custom Field Content as Lady's Watch will be saved as Lady\'s Watch and will be displayed as Lady\'s Watch on the frontend.

Is this expected?



Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

I just checked this and it seems to be working as expected.

It is true that the saved version of the field has the apostrophe escaped, but it is only shown with the escaping backslash on the front-end if you choose to display the raw value of the field.

If you output the field showing the display text then that is shown normally, with the text and apostrophe and no backslash.

I think it is unavoidable that the apostrophe is escaped for the saved value of the field.


Hi Nigel

That's interesting because if Lady's Watch is entered as a value for a single line field, the apostrophe isn't escaped. I get why it ought to be escaped but there's some inconsistency here.

What do you think?


Christian Cox

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Hi, I think the main difference here is that radio field contents are expected to be stored as simple text for ease of filtering. For example, it would be more appropriate to store the contents of a radio field without capitalization or special characters so it is easier to compare those values when performing a custom search based on the radio field selection. That's why I always recommend using simple text characters and numbers in the values of a radio or select custom field - it makes filtering and sorting easier and more intuitive for the system. Otherwise you have to worry about escaped characters and so forth, which makes the filtering mechanism unnecessarily complex. The raw database values should be simple for this reason. That's my understanding of the difference here.


Hi Christian

I can see why it makes sense to keep radio field values simple. Why though are apostrophes in those fields escaped when saved to the database but apostrophes in single and multiple line fields are not? (I'm not trying to build a case for the radio field behaviour to be changed, I'm just looking to understand).



Christian Cox

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I don't have a good answer to that question, I'm sorry!