Difference between #1 and #2 of
How to extend CFormatter, add i18n support to booleanFormat and use it in CDetailView

Revision #2 has been created by thelfensdrfer on Feb 20, 2012, 1:54:33 AM with the memo:

Spelling mistake
« previous (#1) next (#3) »

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 th
ae 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.

If the application language is different from english, say german, it would look much nicer if 0 became 'Nein' and 1 became 'Ja'. The first thing that comes to (my) mind is to override the `booleanFormat` property in the config file like this:
[...]
9 0
9 followers
Viewed: 13 945 times
Version: 1.1
Category: How-tos
Written by: c@cba
Last updated by: c@cba
Created on: Feb 20, 2012
Last updated: 6 years ago
Update Article

Revisions

View all history