Reputation: 330
I use cakephp 2.6.4. and sql srv 2012. I need to save decimal number in format decimal(4,2) -> 4 digits before , and 2 after separator.
In sql server i have data type decimal(4,2) and in model i have validation 'rule' => array('decimal',2).
When i try to save for example 4213,12 it reports message need to round number to 4213 or 4214 I tryed with dot (.) as delimiter, but not works
When i set data type in sql srv float, then i can save, but does not work with decimal,
Any help please? Tnx
next i tryed with numeric(4,2) in sql srv, but same thing as with decimal(4,2)
my validate array is: 'coordinate_x' => array( 'numeric' => array( 'rule' => array('decimal',2),
-and everything alse is commented
Upvotes: 0
Views: 1721
Reputation: 330
Resolwed with HTML requirement:
<input type="number" step="0.01">
Upvotes: 3
Reputation: 426
$this->Number->format();
can be used to change the format of the number.
Example:
$this->Number->format(floor($session->read('max_price')),
array('escape' => false,
'places' => 0,
'thousands' => ','
));
Place attribute is used to set the decimal value .
Upvotes: 1