PHP code example of kartik-v / yii2-number

1. Go to this page and download the library: Download kartik-v/yii2-number library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kartik-v / yii2-number example snippets


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'],
]);