octobercms - 是否可以更改开关的文本?
解决方案
是的,您绝对需要为字段添加其他属性。
你可以在这里找到完整的参考:https ://octobercms.com/docs/backend/forms#field-switch
my_switch:
label: Yes/No
type: switch
comment: Just Example
on: myauthor.myplugin::lang.models.mymodel.my_switch.on <- this
off: myauthor.myplugin::lang.models.mymodel.my_switch.off <- n this
现在对于语言文件,请参考:https ://octobercms.com/docs/plugin/localization#file-structure
您需要为此添加语言字符串。或者如果您不希望它用于多语言,您可以直接应用它
my_switch:
label: Yes/No
type: switch
comment: Just Example
on: Yes <- this
off: No <- n this
以上示例仅适用于单个表单字段切换。
要使其在后端的整个站点范围内工作,请参考:https ://octobercms.com/docs/plugin/localization#overriding
你需要创建新的语言文件
lang/ <=== App localization directory
en/ <=== Language directory
backend/ <=== Plugin / Module directory
lang.php <=== Localization override file
并且你需要添加这个语言数组来覆盖文本、lang.php 文件内容
<?php
return [
'form' => [
'field_off' => 'Off',
'field_on' => 'On'
]
];
如有任何疑问,请发表评论。
推荐阅读
- php - 如何为 WooCommerce 创建多个结帐页面?
- mysql - 我们如何在不使用主键和外键的情况下保持引用完整性
- android - Android分页库,无尽的RecyclerView,改造
- mysql - Where vs Have - 为什么我在设置日期条件时会得到不同的结果?(Mysql)
- java - Hibernate / JPA 如何获取或创建(实体)并使获取返回未提交的已保存实体
- c# - Microsoft.Azure.ServiceBus 如何获取消息状态
- javascript - 根据将下一个状态与前一个状态进行比较来更新状态 - 钩子?
- c# - PropertyGrid 控件如何显示两层嵌套的动态 JSON 对象?
- java - 在 android 中显示 tif/tiff 图像
- rest - 使用 http PUT 方法查询参数 - REST API