CodeIgniter Forums

Full Version: CI4 Model Return "&" Instead of "&"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do you prevent the CI4 model from returning "&" instead of "&" when pulling text from the database?  This behavior is desired when I would like to pass data to a view for display, but it is very undesirable when I want to pass data to an input field that is part of an update form view.
Have you looked in the database how the string is saved? if you use in form a wyswyg, all html are encoded like the "&".
(09-22-2020, 06:51 AM)nicojmb Wrote: [ -> ]Have you looked in the database how the string is saved? if you use in form a wyswyg, all html are encoded like the "&".

I checked, and it is being saved correctly in the database. However, nicojmb's suggestion prompted me to dig a little deeper. The CI4 model is, in fact, returning "&" and not "&" as it should.  It is the Form Helper's set_value() function that is swapping "&" for "&".  I did not pay close enough attention to the documentation, and did not set the $html_escape flag to FALSE.  All is well now.
(09-22-2020, 07:30 AM)mlurie Wrote: [ -> ]
(09-22-2020, 06:51 AM)nicojmb Wrote: [ -> ]Have you looked in the database how the string is saved? if you use in form a wyswyg, all html are encoded like the "&".

I checked, and it is being saved correctly in the database. However, nicojmb's suggestion prompted me to dig a little deeper. The CI4 model is, in fact, returning "&" and not "&" as it should.  It is the Form Helper's set_value() function that is swapping "&" for "&".  I did not pay close enough attention to the documentation, and did not set the $html_escape flag to FALSE.  All is well now.

Great!!