Decimal fields

Status
Not open for further replies.

luca.decarlo

New Member
I'm trying to use the fields to enter decimal values formatted in "Italian", i.e. with the "." thousands separator and "," decimal separator: e.g. 1,000,000.00 (one million). once configured the field with plug-in as "field", then in the "Advanced" tab, input type --> "Number", in the Formatting tab, Format -> decimal, number format -> yes, Thousands separator -> "." and decimal separator -> ","

In the list I see the entered values, but if I try to modify them the field appears empty, if I press "save" I get an error: Store row failed: 22007, 1366, Incorrect decimal value: '' for column `j4`.`counts` .`do-it-yourself_litres` at row 1 ; Please inform your website owner
the attached the screenshots
 

Attachments

  • Screenshot 2023-06-21 143830.png
    Screenshot 2023-06-21 143830.png
    100 KB · Views: 63
  • Screenshot 2023-06-21 143847.png
    Screenshot 2023-06-21 143847.png
    89.6 KB · Views: 56
  • Screenshot 2023-06-21 144210.png
    Screenshot 2023-06-21 144210.png
    92.6 KB · Views: 59
Don't use input type = number (it's a setting for the browser), keep text.
Obviously the browser's "number" format is conflicting with your number format.

Storing empty int/dec values as NULL also with number format enabled will be fixed in the next release.

You can change line 7091 in components\com_fabrik\models\element.php to
if (!$params->get('field_use_number_format', false) || is_null($val))
 
Ok Thanks for the reply.

To go on I had already set it to "text", but so obviously it doesn't format the numbers!

I corrected the line you indicated but nothing changes!
 
In "Advanced" Input type = Text
In "Formatting" Number Format" = Yes + your format characters
is working fine on my site.
 
In "Advanced" Input type = Text
In "Formatting" Number Format" = Yes + your format characters
is working fine on my site.

I downloaded the latest update, but nothing has changed!
If I set number format, it does not format, it formats the number in "Italian" (e.g. one thousand 1,000.00) and above all if I edit the record, it gives me the corresponding empty box!
 

Attachments

  • Screenshot 2023-06-28 185838.png
    Screenshot 2023-06-28 185838.png
    103.4 KB · Views: 51
  • Screenshot 2023-06-28 185848.png
    Screenshot 2023-06-28 185848.png
    99.3 KB · Views: 48
  • Screenshot 2023-06-28 185905.png
    Screenshot 2023-06-28 185905.png
    86.7 KB · Views: 49

Attachments

  • Screenshot 2023-06-29 081105.png
    Screenshot 2023-06-29 081105.png
    104.5 KB · Views: 50
  • Screenshot 2023-06-29 081253.png
    Screenshot 2023-06-29 081253.png
    89.6 KB · Views: 52
  • Screenshot 2023-06-29 081305.png
    Screenshot 2023-06-29 081305.png
    100.7 KB · Views: 51
Ah yes, it's doing a float on the formatted string.
Will be fixed in
the next release.
You can exchange plugins\fabrik_element\field\field.php with
field.zip
 

Attachments

  • field.zip
    6.3 KB · Views: 80
Ok Thanks, it works!

For calculated fields in currency format, there is a similar display problem!, ie entering the value "%.2f" in the "string format" field does not display the correct separators.
 

Attachments

  • Screenshot 2023-06-30 085855.png
    Screenshot 2023-06-30 085855.png
    98.3 KB · Views: 48
3 other small problems:

1. If I display the totals by columns: if the columns are "numeric" fields the total is correct and the format is correct, if they are calculated fields the total is incorrect and the format is also incorrect.

2. when I insert a new record and I have a field with the division "/" , I get the error "divide by zero"!

3. in the total row if I leave the label field empty it still shows the word "sum"
 

Attachments

  • Screenshot 2023-06-30 155951.png
    Screenshot 2023-06-30 155951.png
    125.6 KB · Views: 49
  • Screenshot 2023-06-30 160002.png
    Screenshot 2023-06-30 160002.png
    84.8 KB · Views: 48
Column calculation is done via SQL from the values in the database.

1. You can't use calc elements which are storing the string with your individual (non-sql) formatting and then do SQL calculations.
2. If you are dividing you must make sure to have a valid divisor e.g. by setting a default value !=0
3. sum is the default for empty labels. You may use e.g.  
 
I'm doing some testing and I've made some progress ...

1. I use the custom calculation and do the sum of the individual columns: eg. sum(litres_prepay) + sum(litres_do_it_yourself) + sum(litres_served), but if I try to use the function format(number, 'c', 'IT-it') it only eliminates the decimals. (Totale Lt. screenshot)

2. How do I set a non-zero value if the error comes from when I add a record so the fields are all empty.

3. Ok &nbsp it works correctly

Thank you

Luca
 

Attachments

  • Screenshot 2023-07-01 100536.png
    Screenshot 2023-07-01 100536.png
    120.4 KB · Views: 47
1. ....."so maybe format(number, 2, 'IT-it')" ... I had already tried it, but it doesn't work, it returns the number without decimals.

2. Yes, of course, when I add a new record the fields are all yet to be filled in. then it returns the "divide by zero" error!
 
1. What did you put exactly? It should be something like
format(( sum(column1)+sum(col2)),3,'DE-de')
in Custom Query.
2. Where and how are you doing a division?
 
1. with 'DE-de' i can see the decimal digit, but the format is not correct (see image)
2. calculation code: return number_format(('{conteggi___litri_fai_da_te}' + '{conteggi___litri_prepay}' + '{conteggi___litri_servito}') / (int)'{conteggi___giorni_mese}', 2, ",",".")
 

Attachments

  • Screenshot 2023-07-03 182017.png
    Screenshot 2023-07-03 182017.png
    2.9 KB · Views: 44
As I said:
What are you doing where?
number_format is php in e.g. in a calc element
format( Sum... is SQL in e.g. element list calculations Custom settings

These functions don't have the same parameters, don't mix up.

Gesendet von meinem SM-G930F mit Tapatalk
 
The operation is in a calculation element, I attach the screenshot of the 2 fields. in the list it works correctly, but if I try to add a new record it gives the divide by zero. Surely it does the calculation before it can enter the values.
 

Attachments

  • Screenshot 2023-07-04 174548.png
    Screenshot 2023-07-04 174548.png
    93.3 KB · Views: 46
  • Screenshot 2023-07-04 174607.png
    Screenshot 2023-07-04 174607.png
    106.5 KB · Views: 49
If you are dividing you must make sure to have a valid divisor
So test in your code, something like (you should always quote placeholders in php in case they are empty)
$x = (int)'{your-field}';
if ($x==0) {
return something without division;
}
else {
....
}
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top