Skip Navigation

[Resolved] Apostrophe in Custom Field Content for Radio Fields

This support ticket is created 3 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.

Our next available supporter will start replying to tickets in about 1.45 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 3 voices.

Last updated by Christian Cox 3 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1906343

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?

#1906383

Nigel
Supporter

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

Timezone: Europe/London (GMT+00: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.

#1906619

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?

#1906887

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.

#1907929

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).

Thanks

#1908251

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

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