Index: branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php =================================================================== diff -u -r5618 -r5727 --- branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5618) +++ branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5727) @@ -1720,7 +1720,7 @@ // no main config of such type return false; } - + // 1. get custom field information $sql = 'SELECT * FROM '.TABLE_PREFIX.'CustomField @@ -1731,32 +1731,44 @@ // config doesn't have custom fields return false; } - + // 2. create fields (for customdata item) $fields = $this->Application->getUnitOption($event->Prefix, 'Fields', Array()); $field_options = Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'db_type' => 'text', 'default' => ''); foreach ($custom_fields as $custom_id => $custom_params) { $fields['cust_'.$custom_id] = $field_options; } $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); - + // 3. create virtual & calculated fields (for main item) $calculated_fields = $this->Application->getUnitOption($main_prefix.'.', 'CalculatedFields', Array()); $virtual_fields = $this->Application->getUnitOption($main_prefix, 'VirtualFields', Array()); - + $cf_helper =& $this->Application->recallObject('InpCustomFieldsHelper'); $field_options = Array('type' => 'string', 'not_null' => 1, 'default' => ''); $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - $option_types = Array('select', 'radio'); + foreach ($custom_fields as $custom_id => $custom_params) { - if (in_array($custom_params['ElementType'], $option_types) && $custom_params['ValueList']) { - $field_options['options'] = $cf_helper->GetValuesHash($custom_params['ValueList']); - $field_options['formatter'] = 'kOptionsFormatter'; + switch ($custom_params['ElementType']) { + case 'date': + case 'datetime': + unset($field_options['options']); + $field_options['formatter'] = 'kDateFormatter'; + break; + + case 'select': + case 'radio': + if ($custom_params['ValueList']) { + $field_options['options'] = $cf_helper->GetValuesHash($custom_params['ValueList']); + $field_options['formatter'] = 'kOptionsFormatter'; + } + break; + + default: + unset($field_options['options'], $field_options['formatter']); + break; } - else { - unset($field_options['options'], $field_options['formatter']); - } - + $custom_name = $custom_params['FieldName']; $calculated_fields['cust_'.$custom_name] = 'cust.'.$ml_formatter->LangFieldName('cust_'.$custom_id); if (!isset($virtual_fields['cust_'.$custom_name])) {