shell i format my numbers 1234.20 => 1'234.20
in model or in view using php and codeigniter?
views:
65answers:
3
+3
A:
In the view, since the transformation is presentational in nature.
Artefacto
2010-07-13 12:38:57
+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
2010-07-13 12:39:04
+1 absolutely view layer
Techpriester
2010-07-13 12:40:00
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
2010-07-13 12:41:41
@helle Use the [`NumberFormatter`](http://pt2.php.net/manual/en/class.numberformatter.php), which is locale-aware.
Artefacto
2010-07-13 12:43:29
is there a best practice in codeigniter for numberformatter
helle
2010-07-13 12:50:00
is it native php?
helle
2010-07-13 12:57:38
A:
I would format it in the view, because this sperates the visual from the rest.
Jakub
2010-07-13 12:40:22