Fix reset extrafields that must be unique when cloning
This commit is contained in:
parent
9415486059
commit
7fb2b1a769
@ -202,7 +202,7 @@ class MyObject extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function createFromClone(User $user, $fromid)
|
public function createFromClone(User $user, $fromid)
|
||||||
{
|
{
|
||||||
global $hookmanager, $langs;
|
global $langs, $hookmanager, $extrafields;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
@ -222,6 +222,20 @@ class MyObject extends CommonObject
|
|||||||
$object->ref = "copy_of_".$object->ref;
|
$object->ref = "copy_of_".$object->ref;
|
||||||
$object->title = $langs->trans("CopyOf")." ".$object->title;
|
$object->title = $langs->trans("CopyOf")." ".$object->title;
|
||||||
// ...
|
// ...
|
||||||
|
// Clear extrafields that are unique
|
||||||
|
if (is_array($object->array_options) && count($object->array_options) > 0)
|
||||||
|
{
|
||||||
|
$extrafields->fetch_name_optionals_label($this->element);
|
||||||
|
foreach($object->array_options as $key => $option)
|
||||||
|
{
|
||||||
|
$shortkey = preg_replace('/options_/', '', $key);
|
||||||
|
if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey]))
|
||||||
|
{
|
||||||
|
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
|
||||||
|
unset($object->array_options[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$object->context['createfromclone'] = 'createfromclone';
|
$object->context['createfromclone'] = 'createfromclone';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user