kartik-v/yii2-money An advanced money mask input for Yii 2.0 based on jquery maskmoney plugin styled for Bootstrap 3.


Krajee Logo
yii2-money Donate

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads


This extension has been replaced with the yii2-number extension since Jan 2018. This extension will not be enhanced further or supported. Recommend to head over to yii2-number extension docs and demos for enhanced number management functionality for Yii2.

An advanced money mask input for Yii Framework 2 based on jQuery-maskMoney plugin. The plugin offers a simple way to create masks to your currency form fields. The yii2-money extension includes these additional enhancements in order to use the maskMoney plugin effectively:

  • default styling for Bootstrap 3 and supports Yii Active Field validations
  • automatically read a float/decimal and convert it to the money format on field load
  • automatically convert back the field to a float/decimal for saving once the mask is changed (maintains an internal hidden field)
  • allows global settings of the mask money plugin options via Yii::$app->params


You can see detailed documentation on usage of the extension.

Latest Release

The latest version of the extension is release v1.2.2. Refer the CHANGE LOG for details of various releases.


The preferred way to install this extension is through composer.

Note: Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

Either run

$ php composer.phar require kartik-v/yii2-money "dev-master"

or add

"kartik-v/yii2-money": "dev-master"

to the require section of your composer.json file.


Global Settings

You can globally set the plugin options for your money format across the application in the params section of your Yii configuration file. You need to set the maskMoneyOptions in your Yii application params. For example:

'params' => [
    'maskMoneyOptions' => [
        'prefix' => 'US$ ',
        'suffix' => ' c',
        'affixesStay' => true,
        'thousands' => ',',
        'decimal' => '.',
        'precision' => 2, 
        'allowZero' => false,
        'allowNegative' => false,

Formatter Settings

If you have not setup params like above, the plugin will default the thousandSeparator and decimalSeparator from Yii::$app->formatter settings in your configuration file.

'components' => [
    'formatter' => [
        'class' => 'yii\i18n\formatter',
        'thousandSeparator' => ',',
        'decimalSeparator' => '.',


You can configure the widget as shown below. Any plugin option not passed, will be defaulted from the above two sections (params and formatter). Note that properties directly set in pluginOptions at the widget level as shown below, will override other global settings.

use kartik\money\MaskMoney;
echo MaskMoney::widget([
    'name' => 'currency',
    'value' => 122423.18,
    'pluginOptions' => [
        'prefix' => '$ ',


yii2-money is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.


Change Log: yii2-money

Version 1.2.3

Date: 09-Oct-2018

  • Bump composer dependencies.
  • Move all source code to src directory.

Version 1.2.2

Date: 23-May-2017

  • (bug #26, #23, #22, #16, #9): Core plugin custom fixes for right precision handling.
    • fixes mask display bugs when precision is set to zero and suffix is set
    • fixes masking when precision is set but the decimal part length is less than precision length (for example 1400.50 with precision 2 was wrongly displayed as 140.05 - this change fixes this bug where the leading zeros after decimals were omitted)
  • (enh #25, #11, #10): Update to release v3.1.1 of source plugin.
  • (bug #24, #17, #12, #4): Enhance to calculate changed money mask when enter key is pressed.
  • (enh #21, #20): Fix plugin behavior to show default placeholder when allowEmpty is true.
  • (enh #15): New displayInputName property to control display input name attribute.
  • Add composer alias for latest dev master release.
  • Add github contribution and issue/PR logging templates.
  • Update copyright year to current.

Version 1.2.1

Date: 17-Jun-2015

  • (enh #13): Set composer version dependencies.

Version 1.2.0

Date: 25-Nov-2014

  • (enh #7): Enhance widget to use updated plugin registration from Krajee base

Version 1.1.0

Date: 20-Nov-2014

  • (bug #6): Extend from the correct base widget kartik\base\InputWidget.
  • Set dependency on Krajee base components
  • Set release to stable

Version 1.0.0

Date: 01-Jun-2014

  • PSR4 alias change
  • Initial release


GitHub Stars
GitHub Forks



v1.2.3 is the latest of 6 releases

BSD-3-Clause license
22 github stars & 22 github forks
232 downloads in the last day
5140 downloads in the last 30 days
164130 total downloads