Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/formatters/formatter.php
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | |||||
* @param mixed $value | * @param mixed $value | ||||
* @param string $field_name | * @param string $field_name | ||||
* @param kDBItem|kDBList|kDBBase $object | * @param kDBItem|kDBList|kDBBase $object | ||||
* @return mixed | * @return mixed | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function Parse($value, $field_name, &$object) | public function Parse($value, $field_name, &$object) | ||||
{ | { | ||||
$options = $object->GetFieldOptions($field_name); | |||||
if ($value == '') { | if ($value == '') { | ||||
return NULL; | return $options['type'] == 'string' ? $value : null; | ||||
} | } | ||||
$options = $object->GetFieldOptions($field_name); | |||||
$tc_value = $this->TypeCast($value, $options); | $tc_value = $this->TypeCast($value, $options); | ||||
if ($tc_value === false) { | if ($tc_value === false) { | ||||
return $value; // for leaving badly formatted date on the form | return $value; // for leaving badly formatted date on the form | ||||
} | } | ||||
if(isset($options['type'])) { | if(isset($options['type'])) { | ||||
if (preg_match('#double|float|real|numeric#', $options['type'])) { | if (preg_match('#double|float|real|numeric#', $options['type'])) { | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |