What version of the product are you using? On what operating system?
1.1.8 (Ubuntu Hardy)
Please provide any additional information below.
Currently when using the CGridView widget, columns can be formatted using CFormatter instances. While this class provides a fair amount of predefined functions, it would be quite convenient if it'd also support the functions of the CNumberFormatter class. Unfortunately these classes are currently incompatible: the CNumberFormatter suggests it may be extended from CFormatter but there is no common base class.
Eventually it will probably be a good idea to create a common base class for the two (is there a good reason why there is none?), but a quick solution is to just extend CFormatter with a number of functions which call the appropriate CNumberFormatter functions. I've created and attached a patch (against the current SVN, r3430) which does exactly this.
Please let me know what you think about this.
Migrated from http://code.google.com/p/yii/issues/detail?id=2925
qiang.xue said, at 2012-01-01T03:37:10.000Z:
set for 1.1.10 milestone
qiang.xue said, at 2012-01-01T03:37:36.000Z:
@cebe will try to work on this.
I suggest to add format size methods, something like this:
public $sizeFormat=array('base'=>1024, 'decimals'=>2);
* Formats the value as a size in human readable form.
* @params integer value to be formatted
* @return string the formatted result
public function formatSize($value)
$units=array('B', 'KB', 'MB', 'GB', 'TB');
for($i=0; $base<=$value; $i++)
$value=$value / $base;
return round($value, $this->sizeFormat['decimals']).$units[$i];
@jeicd we have this suggestions already in #192 and problems with it are discussed there.