diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 2dc153a5f7f..d4fb779f199 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1251,12 +1251,18 @@ if ($action == 'create') { $objectsav = $object; // Because Expedition is $expe and not $object that is wrongly a duplicate of $objectsrc. $object = $expe; // Propagate extrafieldsvalue from source object to shipment object - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (array_key_exists('options_'.$key, $objectsav->array_options)) { // We take value from order only if extrafield has the same name/key. - $object->array_options['options_'.$key] = $objectsav->array_options['options_'.$key]; + if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && !empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if (array_key_exists('options_'.$key, $objectsav->array_options)) { // We take value from order only if extrafield has the same name/key. + $object->array_options['options_'.$key] = $objectsav->array_options['options_'.$key]; + } } } - $parameters = array('objectsrc' => isset($objectsrc) ? $objectsrc : '', 'cols' => '3', 'socid' => $socid); + $parameters = array( + 'objectsrc' => isset($objectsrc) ? $objectsrc : '', + 'cols' => '3', + 'socid' => $socid + ); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; $object = $objectsav;