我使用format
类型或Switch
类型的YAML语法在Text
下尝试过
format: !e '%s == 0 ? Active : Inactive'
但是不能按预期工作。反正有没有修改控制器?如何显示单词“不活动/活动”而不是“是/否”?
根据documentation,您可以将其写在fields.yaml
文件上:
boolean_column:
label: Boolean option
type: switch
comment: Comment of this
on: Active
off: Inactive
您可以尝试以下方法:
[首先,创建部分内容,例如_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
列的值。