Error on storing negative numbers?

  • o.schwab.talking.business
  • Offline
More
6 years 2 months ago #4618 by o.schwab.talking.business
Error on storing negative numbers? was created by o.schwab.talking.business
I'm using the 3.6.7 PRO Version on latest J 3.8.2.

Here's what I recongnized.

I've got a field in the Form-template called:

<dt><label for="jform_profitloss">Profit/Loss</label></dt>
<dd>{joodb form|profitloss|4}</dd>

After saving f.e. a number like "-0.00453" the negative gets deleted and is stored as "0.00453" in database.

I could not find any hint in documentation.

Any idea?

Please Log in to join the conversation.

More
6 years 2 months ago #4619 by Dirk
Replied by Dirk on topic Error on storing negative numbers?
Could you please tell us the MYSQL FIELD TYPE of field profitloss?

Please Log in to join the conversation.

  • o.schwab.talking.business
  • Offline
More
6 years 2 months ago #4620 by o.schwab.talking.business
Replied by o.schwab.talking.business on topic Error on storing negative numbers?
It's float(8,6)

Please Log in to join the conversation.

More
6 years 2 months ago - 6 years 2 months ago #4621 by Dirk
Replied by Dirk on topic Error on storing negative numbers?
Guess it's a bug.

The minus sign is stripped the form helper class.
Replace line in line 280 of /administrator/components/com_joodb/helpers/form.php
$item->{$fname}= preg_replace("/[^0-9\.,\-]/","",JRequest::getVar($fne, '', 'post', 'string'));
Or replace it with the following file

Attachment form.php-2-3.zip not found

This message has an attachment file.
Please log in or register to see it.

Last edit: 6 years 2 months ago by Dirk.

Please Log in to join the conversation.

  • o.schwab.talking.business
  • Offline
More
6 years 2 months ago #4622 by o.schwab.talking.business
Replied by o.schwab.talking.business on topic Error on storing negative numbers?
what about case float?

Please Log in to join the conversation.

More
6 years 2 months ago #4623 by Dirk
Replied by Dirk on topic Error on storing negative numbers?
Well float and decimal are basicly the same.
Your problem should be solved now.

Btw float(8,6) is not correct because its much to large!!!!
Please use only FLOAT!!!

You mean decimal(8,6)

But this would be for numbers with 2 digits and 6 digits after the point.
12.345678

For Currencies you should choose 8,2

Please Log in to join the conversation.

Moderators: Dirkjoest