From 826bde06566b00d68dcba36f1cb46059daeea4a4 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Mon, 6 Dec 2021 11:19:12 +0100 Subject: [PATCH] FIX set optional from post --- htdocs/adherents/card.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/asset/type.php | 2 +- htdocs/categories/edit.php | 2 +- htdocs/comm/action/card.php | 2 +- htdocs/compta/bank/card.php | 2 +- htdocs/contact/card.php | 2 +- htdocs/core/class/extrafields.class.php | 3 ++- htdocs/don/card.php | 2 +- htdocs/product/stock/card.php | 2 +- htdocs/projet/card.php | 2 +- htdocs/projet/tasks/task.php | 2 +- htdocs/resource/card.php | 2 +- htdocs/user/card.php | 2 +- htdocs/user/group/card.php | 2 +- 15 files changed, 16 insertions(+), 15 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 93c548cef62..0987b3efcf4 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -326,7 +326,7 @@ if (empty($reshook)) $object->public = GETPOST("public", 'alpha'); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; // Check if we need to also synchronize user information diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index d8890836bb7..d404080b2c0 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -175,7 +175,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; $ret = $object->update($user); diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 8df5ffe8c40..b58bb74853c 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -154,7 +154,7 @@ if ($action == 'update' && $user->rights->asset->write) $object->note = trim($comment); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; $ret = $object->update($user); diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index cd8a718279e..10af9ff2b25 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -102,7 +102,7 @@ if ($action == 'update' && $user->rights->categorie->creer) } if (!$error && empty($object->error)) { - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error && $object->update($user) > 0) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fcb33bd544a..b1314a8e702 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -529,7 +529,7 @@ if (empty($reshook) && $action == 'update') } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error) { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 1403ecc66b8..ebc8a479213 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -246,7 +246,7 @@ if ($action == 'update') if (!$error) { // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); } if (!$error) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 3e3e1894a75..0ca5b184f88 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -421,7 +421,7 @@ if (empty($reshook)) $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f37d2e1932c..4d20499b5ba 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2055,7 +2055,8 @@ class ExtraFields foreach ($extralabels as $key => $value) { if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue; - if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && ! GETPOSTISSET('options_'.$key)) continue; + //when unticking boolean field, it's not set in POST + if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && ! GETPOSTISSET('options_'.$key) && $this->attributes[$object->table_element]['type'][$key] != 'boolean') continue; $key_type = $this->attributes[$object->table_element]['type'][$key]; if ($key_type == 'separate') continue; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 3d2e873b5b3..9c7c0a0bcc5 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -118,7 +118,7 @@ if ($action == 'update') $object->modepaymentid = GETPOST('modepayment', 'int'); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if ($object->update($user) > 0) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 1f53d3491fa..1fa34d2f03f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -182,7 +182,7 @@ if (empty($reshook)) $object->fax = GETPOST("fax"); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error) { diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index ab350dc0919..3ec0141bedb 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -276,7 +276,7 @@ if (empty($reshook)) $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index d912286b3c8..228c17328f2 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -102,7 +102,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) $object->progress = $_POST['progress']; // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index b403c0516f9..2204d9c05bf 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -155,7 +155,7 @@ if (empty($reshook)) $object->country_id = $country_id; // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) { $error++; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9b747d9c713..6cce8180502 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -440,7 +440,7 @@ if (empty($reshook)) { } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) { $error++; } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index d70827d357f..8db1e90c72d 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -219,7 +219,7 @@ if (empty($reshook)) { $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'none'))); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;