owl / money
此包已被放弃,不再维护。没有建议替代包。
OctoberCMS 的标签表单小部件。
dev-master / 1.0.x-dev
2015-02-27 18:26 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2021-09-27 12:08:57 UTC
README
OctoberCMS 的货币表单小部件。
安装
要安装 Money 小部件并与您的插件一起使用,请将以下内容添加到您插件的 composer.json
文件中。
"require": { "owl/money": "~1.0@dev" }
接下来,在您的插件 Plugin.php
文件中注册该小部件。
public function registerFormWidgets() { return [ 'Owl\FormWidgets\Money\Widget' => [ 'label' => 'Money', 'code' => 'owl-money' ], ]; }
使用方法
要使用 Money 小部件,只需声明一个字段类型为 owl-money
price: label: Price type: owl-money
可以使用几个参数来自定义货币小部件。定义 thousands
或 decimal
将会改变千位和十位分隔符。定义 prefix
或 suffix
字符串可以在输入前后添加货币符号。最后,将 allowNegative
设置为 true
允许提交负值。
以下示例将接受带有美元前缀的负输入($ -1,234.56
)
price: label: Price type: owl-money prefix: "$ " allowNegative: true
您可能需要动态地定义小部件配置。例如,您的插件可能有一个变量货币符号。这可以像这样实现...
Config::set('owl.formwidgets::money', [ 'prefix' => '$ ', 'placeholder' => '$ 0.00', ]);