Merge pull request #19554 from atm-quentin/FIX_setoptionalfrompost

FIX set optional from post, we cant untick boolean field on product card
This commit is contained in:
Laurent Destailleur
2021-12-08 16:27:41 +01:00
committed by GitHub
15 changed files with 16 additions and 15 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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++;
}

View File

@@ -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)

View File

@@ -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++;
}

View File

@@ -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++;
}

View File

@@ -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;