forked from Wavyzz/dolibarr
NEW : add extrafield option "empty on clone" (#34866)
* NEW : add extrafield option "empty on clone" * NEW : empty extrafield value on clone * Fix : missing parameter in function call --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -6723,17 +6723,21 @@ abstract class CommonObject
|
||||
$attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey];
|
||||
$attributeUnique = $extrafields->attributes[$this->table_element]['unique'][$attributeKey];
|
||||
$attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey];
|
||||
$attributeEmptyOnClone = $extrafields->attributes[$this->table_element]['emptyonclone'][$attributeKey];
|
||||
|
||||
// If we clone, we have to clean unique extrafields to prevent duplicates.
|
||||
// If we clone, we have to clean extrafields having "empty on clone" option on.
|
||||
// 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)) {
|
||||
if (!empty($this->context['createfromclone']) && $this->context['createfromclone'] == 'createfromclone' && (!empty($attributeUnique) || !empty($attributeEmptyOnClone))) {
|
||||
$new_array_options[$key] = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we create product combination, we have to clean unique extrafields to prevent duplicates.
|
||||
// This behaviour can be prevented by external code by changing $this->context['createproductcombination'] value in hook
|
||||
if (!empty($this->context['createproductcombination']) && $this->context['createproductcombination'] == 'createproductcombination' && !empty($attributeUnique)) {
|
||||
$new_array_options[$key] = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Similar code than into insertExtraFields
|
||||
@@ -6755,6 +6759,7 @@ abstract class CommonObject
|
||||
} else {
|
||||
$new_array_options[$key] = null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ($attributeType) {
|
||||
|
||||
Reference in New Issue
Block a user