diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index e25ff129d0e..f6eeb4ad5e9 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -35,6 +35,7 @@ if (empty($conf) || !is_object($conf)) { @phan-var-force Conf $conf @phan-var-force Translate $langs @phan-var-force array $parameters +@phan-var-force Societe $thirdpartytopropagateextrafieldsfrom '; ?> @@ -59,6 +60,17 @@ if (empty($reshook)) { $params['tpl_context'] = $parameters['tpl_context']; } + // By default $thirdpartytopropagateextrafieldsfrom is not set. + // We can have it set to a thirdparty object to propagate also the extrafields from thirdparty to object. + if (!empty($thirdpartytopropagateextrafieldsfrom) && $thirdpartytopropagateextrafieldsfrom instanceof Societe && !empty($thirdpartytopropagateextrafieldsfrom->id)) { + // copy from thirdparty + $tpExtrafields = new Extrafields($db); + $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($thirdpartytopropagateextrafieldsfrom->table_element); + if ($thirdpartytopropagateextrafieldsfrom->fetch_optionals() > 0) { + $object->array_options = array_merge($object->array_options, $thirdpartytopropagateextrafieldsfrom->array_options); + } + } + print $object->showOptionals($extrafields, 'create', $params); }