Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
C
Core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,010
    • Issues 1,010
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • Core
  • Issues
  • #2505

Closed
Open
Created Apr 01, 2021 by jaapjansma@jaapjansmaDeveloper

CiviReport does not localize custom fields of type Number

How to reproduce

  1. Set localization settings: decimal separator to , and thousand separator to .
  2. Add a custom group for cases
  3. Add a custom field of Type Number and Field type Text
  4. Enter a value such as 1,234.56 which is localized 1.234,56
  5. Create a new CiviCase detail report. Check the column to display the custom field.

Expected result

Value of the custom field displayed as 1.234,56

Actual result

Value of custom field is displayed as 1234.56 (note the decimal separator and the missing thousand separator).

Comment

The display value of custom number fields is also broken on the manage case screen.

We have a function CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency to format money fields. However we do not have such a function for number fields with a decimal. So basically nowhere in CiviCRM a number field is formatted according to localization settings. Unless the smarty modifier |crmNumberFormat is used in the template.

A fix should probably happen in CRM_Core_BAO_CustomField::formatDisplayValue, see https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/BAO/CustomField.php#L1187

However I am not exactly sure how to fix this as I could not find a number formatting function such as we have for the money field. Does such a function exists and if so where do I find it?

Edited Apr 01, 2021 by jaapjansma
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None