I have an issue with the html-encoding in the Input library in Codeigniter.
I have a form used to edit the News in the admin side of my project. Here is the HTML code of the title of the news:
echo form_input('title',($title) ? $title : $this->input->post('title'));
When the edit page is loaded, I'm taking the news title and assigning it to $title.After editing, if any validation error occur, the form will be shown again with the posted value in title file. The above code is written with that in mind.
Now coming to the issue, suppose admin enters title as XYZ's survey report, and submits. Then if a validation error occurs for some other field, when the form is loaded, the title field shows
XYZ's survey report
I think in the Input class, the posted valued is html encoded. So my requirement is, if a validation error occurs, I have to html decode the value before showing it in the form.I have tried
echo form_input('title',($title) ? $title : html_entity_decode($this->input->post('title'),ENT_QUOTES));
and it works. But the project is big and has so many form fields. I would be disappointed to know this is the only way to achieve this.