netresearch / config-fields-m2
用于 Magento 2 系统配置开发的自定义配置类型集合。
1.3.0
2022-04-26 09:54 UTC
Requires
- php: ^7.2.0 || ^8.1.0
- magento/framework: ^102.0.0 || ^103.0.0
- magento/module-backend: ^101.0.0 || ^102.0.0
- magento/module-config: ^101.1.0
README
在配置中不再有繁琐的“是/否”下拉菜单。
此 Magento 2 扩展提供了一系列自定义“字段类型”和“前端模型”供在带有系统配置部分的 Magento 2 扩展中使用。
功能
自定义字段类型
- 复选框集:功能上等同于原生 Magento 字段类型
multiselect
- 单选按钮集:功能上等同于原生 Magento 字段类型
select
- 复选框:功能上等同于原生 Magento 字段类型
select
,但使用YesNo
源模型 - 开关:与“复选框”相同,但具有特殊样式
- 带分钟精度的时间:类似于 Magento 字段类型
time
,但隐藏了“秒”的选择。
自定义前端模型块
- 信息框:为您的扩展提供可定制的信息区域
通过 composer 安装
需要 PHP >=7.0 和 Magento >=2.2
composer require netresearch/config-fields-m2:*
使用方法
在您的 Magento 2 扩展的 etc/adminhtml/system.xml
中,在 Netresearch\ConfigFields\Model\Type
下输入某个类型的类名。
例如
<field id="logging" type="Netresearch\ConfigFields\Model\Type\Checkbox"> <label>Logging</label> <button_label>Record messages to Magento logs</button_label> <comment>You must have global logging activated for this to work.</comment> </field> <field id="loglevel" type="Netresearch\ConfigFields\Model\Type\Radioset"> <label>Logging Level</label> <depends> <field id="logging">1</field> </depends> <source_model>Some\Module\Model\Config\Source\LogLevel</source_model> <comment>The log level Debug may result in very large log files.</comment> </field>
自定义前端模型块可以使用通过 <attribute>
节点传递的附加配置值
例如
<field id="plugin-info"> <frontend_model>Netresearch\ConfigTypes\Block\InfoBox</frontend_model> <attribute type="logo">Some_Module::images/logo.svg</attribute> <attribute type="body_template">Some_Module::system/config/infoBoxBody.phtml</attribute> <attribute type="header_template">Some_Module::system/config/infoBoxHeader.phtml</attribute> <attribute type="view_model">Some\Module\ViewModel\Adminhtml\System\InfoBox</attribute> <attribute type="background">#ffcc01</attribute> </field>
可用属性在 Block 源代码文件中进行了文档说明。
支持 & 问题
此扩展提供“原样”,作者不提供或承诺任何支持。然而,对于您遇到的问题,请随时在 GitHub 上创建问题。