kartik-v/yii2-number

Number control and format mask input for Yii2 Framework.

Maintainers

👁 kartik-v

Package info

github.com/kartik-v/yii2-number

Type:yii2-extension

pkg:composer/kartik-v/yii2-number

Fund package maintenance!

Open Collective

Statistics

Installs: 529 227

Dependents: 17

Suggesters: 0

Stars: 22

Open Issues: 3

v1.0.5 2018-12-07 05:56 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause bdbcd0e60a54169f7daa69e5dba9c8547570ce2d

currencyextensionnumberformatwidgetyii2masknumber control

This package is auto-updated.

Last update: 2026-06-19 22:58:26 UTC


README

👁 Krajee Logo

yii2-number 👁 Donate

👁 Latest Stable Version
👁 Latest Unstable Version
👁 License
👁 Total Downloads
👁 Monthly Downloads
👁 Daily Downloads

Note

This extension replaces the yii2-money extension since Jan 2018. The yii2-money extension will not be enhanced further or supported.

A number control input for Yii2 Framework that uses the jQuery input mask plugin (available also via yii/widgets/MaskedInputAsset) to render number input masks. This extension is similar to the DateControl extension for dates, and allows one to control the display and save formats for numbers. The extension thus allows one to setup a number format display mask, use currency prefixes if needed, and modify the decimals and thousand separators. It lastly allow the display fields to be auto calculated as numbers when stored into the database.

Refer detailed documentation and demos.

Release Updates

Refer the CHANGE LOG for updates and changes to various releases.

Install

Either run

$ php composer.phar require kartik-v/yii2-number "@dev"

or add

"kartik-v/yii2-number": "@dev"

to the require section of your composer.json file.

Usage

use kartik\number\NumberControl;

// Normal decimal
echo NumberControl::widget([
 'name' => 'normal-decimal',
 'value' => 43829.39,
]);

// Integer only
echo NumberControl::widget([
 'name' => 'integer-only',
 'value' => 32892,
 'maskedInputOptions' => ['digits' => 0],
]);

// Currency style with prefix and suffix
echo NumberControl::widget([
 'name' => 'currency-num',
 'value' => 2018032.22,
 'maskedInputOptions' => ['prefix' => '$ ', 'suffix' => ' c'],
]);

// Usage with model 
$model->currency = 1298132.23;
echo NumberControl::widget([
 'model' => $model,
 'attribute' => 'currency',
 'maskedInputOptions' => ['prefix' => '$ ', 'suffix' => ' c'],
]);

License

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