Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

october-widgets/money

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Money

Money form widget for OctoberCMS.

Packagist

Installation

To install the Money widget with your plugin, add the following to your plugin's composer.json file.

"require": {
    "owl/money": "~1.0@dev"
}

Next, register the widget in your plugin's Plugin.php file.

public function registerFormWidgets()
{
    return [
        'Owl\FormWidgets\Money\Widget' => [
            'label' => 'Money',
            'code' => 'owl-money'
        ],
    ];
}

Usage

To use the Money widget, simply declare a field type as owl-money

price:
    label: Price
    type: owl-money

There are several parameters that can be used to customize the money widget. Defining a thousands or decimal will change the thousands and decimal characters. Defining a prefix or suffix string will allow you to add currency symbols before or after the input. Lastly, setting allowNegative to true will allow negative values to be submitted.

The below example will accept negative inputs with a USD prefix ($ -1,234.56)

price:
    label: Price
    type: owl-money
    prefix: "$ "
    allowNegative: true

You may need to define the widget configuration dynamically. For example, your plugin might have a variable currency symbol. This can be achieved like so...

Config::set('owl.formwidgets::money', [
    'prefix'        => '$ ',
    'placeholder'   => '$ 0.00',
]);

About

[READ ONLY] Subtree split of the Money widget (see october-widgets/library)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published