2

I'm having some trouble where my display_fields() function is converting my json encoded data from $data into htmlentities().

Here's my function:

function display_field($data)
{
    error_log($data);
}

Return:

[{"approved":true}]

Stored in database as:

[{"approved":true}]
2
  • I also toyed around with the field_ft_xxx field in the database setting it to "none" and NULL which produced the same result. :( Aug 16, 2013 at 20:55
  • I would suggest searching out another field type that stores it's data using JSON and see how that handles it... Aug 19, 2014 at 18:01

1 Answer 1

2

The comments on the official documentation page note the following:

Just a note that on display_field the data has htmlspeciachars on it if you’re trying to deserialize or decode_json so make sure you do this:

htmlspecialchars_decode($data)

Before you try and decode it.

So to apply that same thing in your case, you'd need:

function display_field($data) { error_log( htmlspecialchars_decode($data) ); }

1
  • 1
    I'll note that the comment is from 2010. I'm not able to look at the codebase at the moment, but I'll update this answer when I've verified if htmlspecialchars is still automatically applied. Aug 19, 2014 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.