Changes
Title
unchanged
How to extend CFormatter, add i18n support to booleanFormat and use it in CDetailView
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
CDetailView, CFormatter, translation, i18n, boolean, view
Content
changed
[...]
'ID',
'Logged:boolean',
),
));
```
In this case, the formatBoolean() method of the class CFormatter will be applied to thae attribute value (see the [class reference](http://www.yiiframework.com/doc/api/1.1/CFormatter#formatBoolean-detail "") for details). This essentially replaces 0 with a 'No', and 1 with a 'Yes', which looks much nicer.
To be exact: the class CFormatter has a public property named `booleanFormat` which defaults to `array('No', 'Yes')`. The `formatBoolean()` method replaces a 0 with its first element, and a 1 with its second element.[...]
<br>
It is that easy to add new and more complicated formatters and simplify your CDetailView calls. Same goes for CGridView.