multiple select error
June 22, 2006
Problem: when i try to use a multiple select tag, I always encounter this error after i submit the form
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /path/to/cake/lib/cake/basics.php on line 436
Obviously, its asking for string instead of array (which is what the mulitple select tag will pass) . So, i just change it to accept array..
function h($text) {
if (is_array($text)) {
foreach ($text as $val) {
$new[] = htmlspecialchars($val);
}
} else {
$new = htmlspecialchars($text);
}
return $new;
//return htmlspecialchars($text); // this is the old code
}
Another problem: it cannot automatically select the selected items.
Solution: I’d post this some other day
hehe.. need to get back to work ..
Entry Filed under: baking tips, cakephp. .
Trackback this post | Subscribe to the comments via RSS Feed