gpt4 book ai didi

OctoberCMS 后端列表格式数字字段作为货币

转载 作者:行者123 更新时间:2023-12-02 09:22:17 24 4
gpt4 key购买 nike

想知道是否有一种简单的方法来格式化后端列表列值。将数值作为货币的示例

最佳答案

晚了,但供引用:

如果仅用于后端列表,您可以轻松创建一个新的列类型 Currency 并使用它。 see documentation

在您的情况下,您将在 Plugin.php 中添加以下内容:

public function registerListColumnTypes()
{
return [
'currency' => function($value) {
return money_format( $value, 2);
}
];
}

现在您可以在插件的每个 coulmns.yaml 中使用它:
columns
title:
label: Title
type: text
amount:
type: currency
label: Amount

关于OctoberCMS 后端列表格式数字字段作为货币,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41575574/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com