Index: trunk/kernel/units/config_search/config_search_event_handler.php =================================================================== diff -u -N -r4670 -r6093 --- trunk/kernel/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 4670) +++ trunk/kernel/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 6093) @@ -60,7 +60,7 @@ } /** - * Enter description here... + * [HOOK] Enter description here... * * @param kEvent $event */ @@ -75,12 +75,11 @@ $object =& $event->getObject( Array('skip_autoload' => true) ); $custom_id = $custom_field->GetID(); - if ($custom_id) { + if ($object->GetDBField('CustomFieldId') != $custom_id) { $object->Load($custom_id, 'CustomFieldId'); - $object->SetDBField('CustomFieldId', $custom_id); // for cloning only } - - $cf_search = Array(); + + $cf_search = Array(); $cf_search['DisplayOrder'] = $custom_field->GetDBField('DisplayOrder'); $cf_search['ElementType'] = $custom_field->GetDBField('ElementType'); $cf_search['DisplayName'] = $custom_field->GetDBField('FieldLabel'); @@ -96,6 +95,7 @@ $cf_search['ModuleName'] = $this->Conn->GetOne($sql); $object->SetFieldsFromHash($cf_search); + $object->SetDBField('CustomFieldId', $custom_id); $result = $object->isLoaded() ? $object->Update() : $object->Create(); }