Index: branches/5.2.x/core/kernel/utility/formatters/date_formatter.php =================================================================== diff -u -N -r14572 -r14596 --- branches/5.2.x/core/kernel/utility/formatters/date_formatter.php (.../date_formatter.php) (revision 14572) +++ branches/5.2.x/core/kernel/utility/formatters/date_formatter.php (.../date_formatter.php) (revision 14596) @@ -1,6 +1,6 @@ $field_name, 'formatter' => 'kDateFormatter', 'format' => $display_format['date'], 'input_format' => $input_format['date']); - $copy_options = Array ('default', 'required', 'use_timezone', 'error_msgs'); + $copy_options = Array ('type', 'default', 'required', 'use_timezone', 'error_msgs'); foreach ($copy_options as $copy_option) { if (array_key_exists($copy_option, $field_options) ) { $opts[$copy_option] = $field_options[$copy_option]; @@ -157,15 +157,27 @@ $object->setVirtualFields($add_fields); } - function UpdateSubFields($field, $value, &$options, &$object) + /** + * Used for split fields like timestamp -> date, time + * Called from DBItem to update sub fields values after loading item + * + * @param string $field + * @param string $value + * @param Array $options + * @param kDBItem $object + * @return void + * @access public + */ + public function UpdateSubFields($field, $value, &$options, &$object) { - if ( $sub_fields = getArrayValue($options, 'sub_fields') ) { - if( isset($value) && $value ) - { - $object->SetDBField( $sub_fields['date'], $value ); - $object->SetDBField( $sub_fields['time'], $value ); - } + $sub_fields = getArrayValue($options, 'sub_fields'); + + if ( !$sub_fields || !isset($value) || !$value ) { + return ; } + + $object->SetDBField($sub_fields['date'], $value); + $object->SetDBField($sub_fields['time'], $value); } /** @@ -210,7 +222,15 @@ } } -//function Format($value, $options, &$errors) + /** + * Formats value of a given field + * + * @param string $value + * @param string $field_name + * @param kDBItem|kDBList $object + * @param string $format + * @return string + */ function Format($value, $field_name, &$object, $format=null) { if ( is_null($value) ) return ''; @@ -331,9 +351,10 @@ * @param mixed $value * @param string $field_name * @param kDBItem $object - * @return string + * @return mixed + * @access public */ - function Parse($value, $field_name, &$object) + public function Parse($value, $field_name, &$object) { $options = $object->GetFieldOptions($field_name);