项目作者: kartik-v

项目描述 :
A number format mask control and input for Yii2 Framework
高级语言: PHP
项目地址: git://github.com/kartik-v/yii2-number.git
创建时间: 2018-01-30T06:25:23Z
项目社区:https://github.com/kartik-v/yii2-number

开源协议:Other

下载




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

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

or add

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

to the require section of your composer.json file.

Usage

  1. use kartik\number\NumberControl;
  2. // Normal decimal
  3. echo NumberControl::widget([
  4. 'name' => 'normal-decimal',
  5. 'value' => 43829.39,
  6. ]);
  7. // Integer only
  8. echo NumberControl::widget([
  9. 'name' => 'integer-only',
  10. 'value' => 32892,
  11. 'maskedInputOptions' => ['digits' => 0],
  12. ]);
  13. // Currency style with prefix and suffix
  14. echo NumberControl::widget([
  15. 'name' => 'currency-num',
  16. 'value' => 2018032.22,
  17. 'maskedInputOptions' => ['prefix' => '$ ', 'suffix' => ' c'],
  18. ]);
  19. // Usage with model
  20. $model->currency = 1298132.23;
  21. echo NumberControl::widget([
  22. 'model' => $model,
  23. 'attribute' => 'currency',
  24. 'maskedInputOptions' => ['prefix' => '$ ', 'suffix' => ' c'],
  25. ]);

License

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