views:

65

answers:

3

shell i format my numbers 1234.20 => 1'234.20 in model or in view using php and codeigniter?

+3  A: 

In the view, since the transformation is presentational in nature.

Artefacto
+5  A: 

It belongs to the view layer.
The model only cares about the value, not how you present it to the user. Also, you may need to display it differently, if your site is multilingual.

Maerlyn
+1 absolutely view layer
Techpriester
well yes it is multilingual, but the language stuff is not handled by different templates. shell i use a pattern for sprintf() which depends on the language? and put a sprintf() in my view?
helle
@helle Use the [`NumberFormatter`](http://pt2.php.net/manual/en/class.numberformatter.php), which is locale-aware.
Artefacto
is there a best practice in codeigniter for numberformatter
helle
is it native php?
helle
A: 

I would format it in the view, because this sperates the visual from the rest.

Jakub