Welcome Guest, Not a member yet? Register   Sign In
Is it safe to use Form_validation with the form helpers?
#1

[eluser]KeithB[/eluser]
Hi,

Given that the run() method of the Form_validation class seems to automatically encode special characters to entity codes when validation fails, is it safe to repopulate the form elements with the form helper functions? These functions also encode the characters, and I'm worried that there is a risk of things being encoded twice.

Also, I've been unable to find any reference about the run() method automatically encoding things, so I'm making assumptions about that based on the last few hours of working with a form. Is this assumption correct, and is it in fact documented somewhere? I'm quite tired, so there's a good chance that I've missed something.

Thanks,
Keith
#2

[eluser]Michael Wales[/eluser]
The set_ functions within the form helper take care of the decoding - it is fine to use the form_validation library and form helpers together (you are encouraged to do so, actually).

Here's an excerpt from form_helper.php that all the set_ functions call:
Code:
$str = htmlspecialchars($str);

// In case htmlspecialchars misses these.
$str = str_replace(array("'", '"'), array("'", """), $str);
#3

[eluser]KeithB[/eluser]
Okay, thanks Michael.




Theme © iAndrew 2016 - Forum software by © MyBB