Index: trunk/core/kernel/db/db_event_handler.php =================================================================== diff -u -r4000 -r4008 --- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4000) +++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4008) @@ -1576,14 +1576,15 @@ $item_type = $this->Application->getUnitOption($main_prefix, 'ItemType'); $sql = 'SELECT FieldName, CustomFieldId FROM '.TABLE_PREFIX.'CustomField - WHERE Type = '.$item_type; + WHERE Type = '.$item_type.' + ORDER BY CustomFieldId'; $custom_fields = $this->Conn->GetCol($sql, 'CustomFieldId'); // 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_name) { - $fields['cust_'.$custom_name] = $field_options; + $fields['cust_'.$custom_id] = $field_options; } $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);