Active
Project:
Views Aggregator Plus
Version:
2.1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Nov 2024 at 14:05 UTC
Updated:
8 Nov 2024 at 02:47 UTC
Jump to comment: Most recent
Usage in custom text in View:
{% set total_price = total_price__number_1|render|number_format(2, '.', '')%}
Error triggered:
TypeError: number_format(): Argument #2 ($decimals) must be of type int, string given in number_format() (line 859 of /home/pumpbooks/live.pumptechnicalbooks.com/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php).
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
toddses commentedCasting the value to int seems to resolve the issue.
Line 859: $rendered_values[] = number_format($new_value, $custom_delimiters[0] ?? 0, $custom_delimiters[1] ?? '.', $custom_delimiters[2] ?? '');
Potential fix: $rendered_values[] = number_format($new_value, (int) $custom_delimiters[0] ?? 0, $custom_delimiters[1] ?? '.', $custom_delimiters[2] ?? '');
Comment #3
tr commentedYes, that seems to be the correct fix. I'd like to clean up that piece of code a bit and write a test case - I'll open a MR soon.