Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calcio/49bb1d0b1b5f6fa4de3ebb711c442dfd to your computer and use it in GitHub Desktop.
Save calcio/49bb1d0b1b5f6fa4de3ebb711c442dfd to your computer and use it in GitHub Desktop.
Custom Formatter
<?php
namespace app\components\formatters;
use yii\i18n\Formatter;
class BrazilianFormatter extends Formatter
{
public static function asStatus($value)
{
return $value ? 'Active' : 'Inactive';
}
public static function asStatusHighlighted($value)
{
return $value ? '<span class="text-info"><strong>Active</strong></span>' :
'<span class="text-warning"><strong>Inactive</strong></span>';
}
public static function asHighlight($value)
{
return $value ? 'Yes' : 'No';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment