marko_b123
marko_b123

Reputation: 330

Cakephp sql decimal input form

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

-and everything alse is commented

Upvotes: 0

Views: 1721

Answers (2)

marko_b123
marko_b123

Reputation: 330

Resolwed with HTML requirement:

<input type="number" step="0.01">

Upvotes: 3

Karthik Keyan
Karthik Keyan

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

Related Questions