Im having a bit of an issue with decoding data coming from a database.
My data is stored in the database as utf8, for this instance the data is ‘corrosion & time’, which is stored as ‘corrosion & time’. Now i want to populate a field of the form with this data, this field has a htmlSpecialChars filter applied.
When viewed in the browser I see:
‘corrosion & time’
If I use html_entity_decode i get:
‘corrosion $amp; time’
and if i also remove the filter from the form i then get:
‘corrosion & time’
Is there anyway i can populate the form without removing the filter from the field?
you are going to have to decode the data before populating the form, the filter should not be applied to the data coming from the form until it’s posted which will reapply the filter when
getValues()is called.If you know you used
htmlspecialcharsto encode the data then usehtmlspecialchars_decodeto decode the data.