mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 20:44:28 +09:00
Fixed a bug for client-side validation
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8948 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
b6bacc388e
commit
03555a065f
1 changed files with 9 additions and 4 deletions
|
|
@ -140,11 +140,13 @@ class Validator
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields = array_map('trim', $fields);
|
$fields = array_map('trim', $fields);
|
||||||
|
$field_names = implode("\t", array_keys($fields));
|
||||||
|
|
||||||
foreach($this->_filters as $key=>$filter) {
|
foreach($this->_filters as $key=>$filter) {
|
||||||
|
$fname = $key;
|
||||||
$exists = array_key_exists($key, $fields);
|
$exists = array_key_exists($key, $fields);
|
||||||
$filter = array_merge($filter_default, $filter);
|
$filter = array_merge($filter_default, $filter);
|
||||||
$value = $exists ? $fields[$key] : null;
|
$value = $exists ? $fields[$fname] : null;
|
||||||
|
|
||||||
// conditional statement
|
// conditional statement
|
||||||
foreach($filter['if'] as $cond) {
|
foreach($filter['if'] as $cond) {
|
||||||
|
|
@ -159,8 +161,8 @@ class Validator
|
||||||
// attr : default
|
// attr : default
|
||||||
if(!$value && strlen($default=trim($filter['default']))) {
|
if(!$value && strlen($default=trim($filter['default']))) {
|
||||||
$value = $default;
|
$value = $default;
|
||||||
if(is_null($fields_)) Context::set($key, $value);
|
if(is_null($fields_)) Context::set($fname, $value);
|
||||||
else $fields_[$key] = $value;
|
else $fields_[$fname] = $value;
|
||||||
}
|
}
|
||||||
$value_len = strlen($value);
|
$value_len = strlen($value);
|
||||||
|
|
||||||
|
|
@ -361,6 +363,7 @@ class Validator
|
||||||
if(preg_match('@(^|/)files/ruleset/\w+\.xml$@i', $this->_xml_path)) $ruleset = '@'.$ruleset;
|
if(preg_match('@(^|/)files/ruleset/\w+\.xml$@i', $this->_xml_path)) $ruleset = '@'.$ruleset;
|
||||||
|
|
||||||
// custom rulesets
|
// custom rulesets
|
||||||
|
$addrules = array();
|
||||||
foreach($this->_rules as $name=>$rule) {
|
foreach($this->_rules as $name=>$rule) {
|
||||||
if(strpos('email,userid,url,alpha,alpha_number,number,', $name.',') !== false) continue;
|
if(strpos('email,userid,url,alpha,alpha_number,number,', $name.',') !== false) continue;
|
||||||
switch($rule['type']) {
|
switch($rule['type']) {
|
||||||
|
|
@ -376,8 +379,10 @@ class Validator
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$addrules = implode('', $addrules);
|
||||||
|
|
||||||
// filters
|
// filters
|
||||||
|
$content = array();
|
||||||
foreach($this->_filters as $name=>$filter) {
|
foreach($this->_filters as $name=>$filter) {
|
||||||
$field = array();
|
$field = array();
|
||||||
|
|
||||||
|
|
@ -407,7 +412,7 @@ class Validator
|
||||||
if(count($content)) {
|
if(count($content)) {
|
||||||
$content = implode(',', $content);
|
$content = implode(',', $content);
|
||||||
|
|
||||||
return "(function($,v){\nv=xe.getApp('validator')[0];if(!v)return;\nv.cast('ADD_FILTER',['{$ruleset}', {{$content}}]);})(jQuery);";
|
return "(function($,v){\nv=xe.getApp('validator')[0];if(!v)return;\n{$addrules}\nv.cast('ADD_FILTER',['{$ruleset}', {{$content}}]);})(jQuery);";
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue