如何在OctoberCMS列表中显示交换机类型的'Inactive / Active'?

问题描述 投票:0回答:2

我使用format类型或Switch类型的YAML语法在Text下尝试过

format: !e '%s == 0 ? Active : Inactive'

但是不能按预期工作。反正有没有修改控制器?如何显示单词“不活动/活动”而不是“是/否”?

php laravel octobercms
2个回答
0
投票

根据documentation,您可以将其写在fields.yaml文件上:

boolean_column:
    label: Boolean option
    type: switch
    comment: Comment of this
    on: Active
    off: Inactive

0
投票

您可以尝试以下方法:

[首先,创建部分内容,例如_active_column.htm,此内容(例如):

<?php if($value){ ?>
    <span class="oc-icon-circle text-success"></span>
<?php }else{ ?>
    <span class="oc-icon-circle text-danger"></span>
<?php } ?>

然后,在columns.yaml中,您可以像这样调用局部函数:

active:
    label   : Active
    type    : partial
    path    : ~/plugins/your/plugin/models/your_model/_active_column.htm

在此示例中,$value从模型中获取active列的值。

© www.soinside.com 2019 - 2024. All rights reserved.