Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving "0" value in numeric fields when it's empty #9440

Closed
SinergiaCRM opened this issue Jan 20, 2022 · 1 comment · Fixed by #9524
Closed

Saving "0" value in numeric fields when it's empty #9440

SinergiaCRM opened this issue Jan 20, 2022 · 1 comment · Fixed by #9524
Labels
Area: Studio Issues & PRs related to all things regarding studio & module builder Priority:Moderate Issues & PRs that are minor; broken styling, cosmetic, warnings - there are practical workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type:Bug Bugs within the core SuiteCRM codebase

Comments

@SinergiaCRM
Copy link
Contributor

In a new module (from the ModuleBuilder) that contains a non-required non-custom/core numeric field (integer or float). If the record is saved without filling that field, the field will display and contain (in DB) a "0" value.

After, if you edit the record, remove the 0 and save it again, it saves fine.

Issue

The numeric fields with default empty value are wrongly filled with a "0" after the saving the record. This happens with non-required non-custom/core numeric field (integer or float) from newly created modules from Module builder

Expected Behavior

It should be saved "null" if no value is set.

Actual Behavior

A "0" value appears on that field.

Possible Fix

Change behaviour of the DBManager for those fields.

Steps to Reproduce

  1. Create a new module in Module Builder
  2. Add an Integer or Decimal field
  3. Add the field to Edit and Detail View
  4. Deploy module
  5. Create a new record to the module, filling only the required name
  6. Check that the numeric field has a "0" value

Context

This is very confusing. It isn't the same a value 0 than an empty one. This should be fixed.

Your Environment

SuiteCRM Version used: Version 7.12.2
Browser name and version: Chrome Versión 97.0.4692.71 (Build oficial) (64 bits)
Environment name and version: MySQL, PHP 7
Operating System and version: Ubuntu 18.04

SinergiaCRM added a commit to SinergiaTIC/SuiteCRM that referenced this issue Jan 20, 2022
@johnM2401 johnM2401 added Area: Studio Issues & PRs related to all things regarding studio & module builder Priority:Moderate Issues & PRs that are minor; broken styling, cosmetic, warnings - there are practical workarounds Type:Bug Bugs within the core SuiteCRM codebase Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution labels Feb 2, 2022
SinergiaCRM added a commit to SinergiaTIC/SuiteCRM that referenced this issue Feb 25, 2022
@gunnicom
Copy link
Contributor

gunnicom commented Oct 30, 2023

I think I fix this like this since years (I tried to integrate that in the original Sugar years ago):

diff --git a/include/database/DBManager.php b/include/database/DBManager.php
index 5d172ba93..0fe7644c4 100644
--- a/include/database/DBManager.php
+++ b/include/database/DBManager.php
@@ -543,7 +543,7 @@ abstract class DBManager
                     continue;
                 }

-                if (isset($data[$field])) {
+                if(isset($data[$field]) && (strlen($data[$field])>0 || $data[$field]===false)) { 
                     // clean the incoming value..
                     $val = from_html($data[$field]);
                 } else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Studio Issues & PRs related to all things regarding studio & module builder Priority:Moderate Issues & PRs that are minor; broken styling, cosmetic, warnings - there are practical workarounds Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type:Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants