Merge pull request #20233 from marc-dll/13.0_FIX_clone_with_unique_extrafields
FIX: object cloning: set unique extrafield values to null to prevent duplicates
This commit is contained in:
commit
0c27578e69
@ -5307,8 +5307,15 @@ abstract class CommonObject
|
||||
$attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey];
|
||||
$attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey];
|
||||
$attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey];
|
||||
$attributeUnique = $extrafields->attributes[$this->table_element]['unique'][$attributeKey];
|
||||
$attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey];
|
||||
|
||||
// If we clone, we have to clean unique extrafields to prevent duplicates.
|
||||
// This behaviour can be prevented by external code by changing $this->context['createfromclone'] value in createFrom hook
|
||||
if (! empty($this->context['createfromclone']) && $this->context['createfromclone'] == 'createfromclone' && ! empty($attributeUnique)) {
|
||||
$new_array_options[$key] = null;
|
||||
}
|
||||
|
||||
// Similar code than into insertExtraFields
|
||||
if ($attributeRequired)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user