Fixed a bug that form validator can't display some error message

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9309 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-09-23 07:18:21 +00:00
parent 0d3ca55707
commit 86777cf4f7
2 changed files with 4 additions and 2 deletions

View file

@ -478,7 +478,7 @@ class Validator
// error messages // error messages
foreach($lang->filter as $key=>$text) { foreach($lang->filter as $key=>$text) {
if($text) { if($text) {
$text = addslashes($text); $text = preg_replace('@\r?\n@', '\\n', addslashes($text));
$messages[] = "v.cast('ADD_MESSAGE',['{$key}','{$text}']);"; $messages[] = "v.cast('ADD_MESSAGE',['{$key}','{$text}']);";
} }
} }

View file

@ -241,7 +241,8 @@
for($i=0;$i<$target_count;$i++) { for($i=0;$i<$target_count;$i++) {
$target = $target_list[$i]; $target = $target_list[$i];
if(!$lang->{$target}) $lang->{$target} = $target; if(!$lang->{$target}) $lang->{$target} = $target;
$js_messages[] = sprintf("v.cast('ADD_MESSAGE',['%s','%s']);", $target, addslashes($lang->{$target})); $text = preg_replace('@\r?\n@', '\\n', addslashes($lang->{$target}));
$js_messages[] = "v.cast('ADD_MESSAGE',['{$target}','{$text}']);";
} }
// writes the target type // writes the target type
@ -257,6 +258,7 @@
// writes error messages // writes error messages
foreach($lang->filter as $key => $val) { foreach($lang->filter as $key => $val) {
if(!$val) $val = $key; if(!$val) $val = $key;
$val = preg_replace('@\r?\n@', '\\n', addslashes($val));
$js_messages[] = sprintf("v.cast('ADD_MESSAGE',['%s','%s']);", $key, $val); $js_messages[] = sprintf("v.cast('ADD_MESSAGE',['%s','%s']);", $key, $val);
} }