Index: branches/RC/core/kernel/db/dbitem.php
===================================================================
diff -u -r9235 -r9267
--- branches/RC/core/kernel/db/dbitem.php (.../dbitem.php) (revision 9235)
+++ branches/RC/core/kernel/db/dbitem.php (.../dbitem.php) (revision 9267)
@@ -132,17 +132,12 @@
if ($value == '') {
$parsed = NULL;
}
- if (isset($options['formatter'])) {
- $formatter =& $this->Application->recallObject($options['formatter']);
-// $parsed = $formatter->Parse($value, $options, $err);
- $parsed = $formatter->Parse($value, $name, $this);
- }
- // this will make sure numeric value is converted to normal representation
+
+ // kFormatter is always used, to make sure, that numeric value is converted to normal representation
// according to regional format, even when formatter is not set (try seting format to 1.234,56 to understand why)
- elseif (preg_match('#int|integer|double|float|real|numeric#', $options['type'])) {
- $formatter =& $this->Application->recallObject('kFormatter');
- $parsed = $formatter->TypeCast($value, $options);
- }
+ $formatter =& $this->Application->recallObject(isset($options['formatter']) ? $options['formatter'] : 'kFormatter');
+ $parsed = $formatter->Parse($value, $name, $this);
+
$this->SetDBField($name,$parsed);
}
@@ -434,6 +429,27 @@
return true;
}
+ function ValidateField($field)
+ {
+ $options = $this->Fields[$field];
+
+ /*if (isset($options['formatter'])) {
+ $formatter =& $this->Application->recallObject($options['formatter']);
+ $formatter->UpdateMasterFields($field, $this->GetDBField($field), $options, $this);
+ }*/
+
+ $error_field = isset($options['error_field']) ? $options['error_field'] : $field;
+ $res = !isset($this->FieldErrors[$error_field]['pseudo']) || !$this->FieldErrors[$error_field]['pseudo'];
+
+ $res = $res && $this->ValidateType($field, $options);
+ $res = $res && $this->ValidateRange($field, $options);
+ $res = $res && $this->ValidateUnique($field, $options);
+ $res = $res && $this->ValidateRequired($field, $options);
+ $res = $res && $this->CustomValidation($field, $options);
+
+ return $res;
+ }
+
/**
* Validate all item fields based on
* constraints set in each field options
@@ -448,25 +464,18 @@
$global_res = true;
foreach ($this->Fields as $field => $params) {
- $error_field = isset($params['error_field']) ? $params['error_field'] : $field;
- $res = !isset($this->FieldErrors[$error_field]['pseudo']) || !$this->FieldErrors[$error_field]['pseudo'];
+ $res = $this->ValidateField($field);
- $res = $res && $this->ValidateType($field, $params);
- $res = $res && $this->ValidateRange($field, $params);
- $res = $res && $this->ValidateUnique($field, $params);
- $res = $res && $this->ValidateRequired($field, $params);
- $res = $res && $this->CustomValidation($field, $params);
$global_res = $global_res && $res;
}
- if (!$global_res && $this->Application->isDebugMode() )
- {
- global $debugger;
- $error_msg = "Validation failed in prefix ".$this->Prefix.", FieldErrors follow (look at items with 'pseudo' key set)
- You may ignore this notice if submitted data really has a validation error ";
- trigger_error( $error_msg, E_USER_NOTICE);
- $debugger->dumpVars($this->FieldErrors);
+ if (!$global_res && defined('DEBUG_MODE') && DEBUG_MODE) {
+ $error_msg = ' Validation failed in prefix '.$this->Prefix.',
+ FieldErrors follow (look at items with "pseudo" key set)
+ You may ignore this notice if submitted data really has a validation error';
+ trigger_error(trim($error_msg), E_USER_NOTICE);
+ $this->Application->Debugger->dumpVars($this->FieldErrors);
}
return $global_res;