0

I tried to set up a number format for living space in Cakephp, it should look like this: "100,00 m²" As I use this format often, I want to create a default format in my AppController beforeFilter():

CakeNumber::addFormat('AREA', array(
    'thousands' => ' ', 
    'decimals' => ',', 
    'places' => 2, 
    'before' => false, 
    'after' => ' m²'
));

In my view file I call: echo $this->Number->currency($area, 'AREA');

The problem: 'after' does not apply, so it is missing "m²", only "100,00" shows up.

I know living space is not a currency, but it looks like the best option to define reusable number format.

Edit solution: Thanks to Mantas:

CakeNumber::addFormat('AREA', array('thousands' => ' ', 
  'decimals' => ',', 
  'places' => 2, 
  'wholeSymbol' => ' m²', 
  'wholePosition' => 'after'
));
Clausi
  • 28
  • 6

1 Answers1

2

You should set [ 'wholeSymbol' => ' m²', 'wholePosition' => 'after', ]

to achieve desired format.

Mantas
  • 4,259
  • 2
  • 27
  • 32