From ada3ed0a7cee3030aba89e1d06effd7f96cacca5 Mon Sep 17 00:00:00 2001 From: Christian Humpel <78662388+Humml87@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:44:36 +0200 Subject: [PATCH] Fix: different behavior on extrafield updates. (#30150) --- htdocs/commande/card.php | 5 +++-- htdocs/compta/facture/card.php | 5 +++-- htdocs/expedition/card.php | 5 +++-- htdocs/fichinter/card.php | 5 +++-- htdocs/supplier_proposal/card.php | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index cd02c46b653..4c935d63ce6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1513,16 +1513,17 @@ if (empty($reshook)) { if ($action == 'update_extras') { $object->oldcopy = dol_clone($object, 2); + $attribute_name = GETPOST('attribute', 'restricthtml'); // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); if ($ret < 0) { $error++; } if (!$error) { // Actions on extra fields - $result = $object->insertExtraFields('ORDER_MODIFY'); + $result = $object->updateExtraField($attribute_name, 'ORDER_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9bddb4de839..14fb3672056 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3070,16 +3070,17 @@ if (empty($reshook)) { if ($action == 'update_extras') { $object->oldcopy = dol_clone($object, 2); + $attribute_name = GETPOST('attribute', 'restricthtml'); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); if ($ret < 0) { $error++; } if (!$error) { // Actions on extra fields - $result = $object->insertExtraFields('BILL_MODIFY'); + $result = $object->updateExtraField($attribute_name, 'BILL_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 6541faf6561..a388a57cc63 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -198,16 +198,17 @@ if (empty($reshook)) { if ($action == 'update_extras') { $object->oldcopy = dol_clone($object, 2); + $attribute_name = GETPOST('attribute', 'restricthtml'); // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); if ($ret < 0) { $error++; } if (!$error) { // Actions on extra fields - $result = $object->insertExtraFields('SHIPMENT_MODIFY'); + $result = $object->updateExtraField($attribute_name, 'SHIPMENT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 006d7da2c8a..dba6a24c4d7 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -750,16 +750,17 @@ if (empty($reshook)) { if ($action == 'update_extras') { $object->oldcopy = dol_clone($object, 2); + $attribute_name = GETPOST('attribute', 'restricthtml'); // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); if ($ret < 0) { $error++; } if (!$error) { // Actions on extra fields - $result = $object->insertExtraFields('INTERVENTION_MODIFY'); + $result = $object->updateExtraField($attribute_name, 'INTERVENTION_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e558de83954..69d0853fbc8 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1132,15 +1132,16 @@ if (empty($reshook)) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOSTINT('calculation_mode')); } elseif ($action == 'update_extras') { $object->oldcopy = dol_clone($object, 2); + $attribute_name = GETPOST('attribute', 'restricthtml'); // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); if ($ret < 0) { $error++; } if (!$error) { - $result = $object->insertExtraFields('PROPOSAL_SUPPLIER_MODIFY'); + $result = $object->updateExtraField($attribute_name, 'PROPOSAL_SUPPLIER_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++;