CodeIgniter Forums
problem of char with form_input() and form_textarea() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: problem of char with form_input() and form_textarea() (/showthread.php?tid=76484)



problem of char with form_input() and form_textarea() - kilden - 05-16-2020

Hello,

I am making a simple form but I'm getting special chars in my input with the functions form_input() and form_textarea()...

like ' for hyphens... I enter an array inside it as


Code:
$message=['name'=>'message', 'id'=>'message', 'value'=> set_value("message",$form_message), 'row'=>'10', 'style'=>'height:100%'];
echo form_textarea($message);

I don't succed escaping htmlspecialchars... If I put "I don't" in my field, I get "I don't" in my textarea while I've got no problem if I don't use the functions form_input() and form_textarea().
How can I fix this ? Do I have to escape this char with addslashes() somewhere ? or remove it by adding something ? 

Thank you for any help


RE: problem of char with form_input() and form_textarea() - kilden - 05-17-2020

Oh... I've found my answer here :
https://forum.codeigniter.com/thread-68257.html

-> if you use set_value() AND form_input(), you should use set_value('var', $projets['var'] FALSE) because both functions "escape" the value.
You can turn off html escaping in set_value, by adding a third parameter.

Thanks again to nunenthal !