piszczek / magento2-inputmask
将 inputMask 参数添加到抽象输入。基于 IMask。
0.0.2
2018-02-05 18:49 UTC
This package is not auto-updated.
Last update: 2024-09-21 00:48:11 UTC
README
这个简单的插件允许向表单 UI 组件配置中添加输入掩码配置。
基于 Imask 并支持大多数配置(除传递 JS 函数作为参数外)。
安装
composer require piszczek/magento2-inputmask
示例
位置 app/code/Your/Module/view/adminhtml/ui_component/your_module_model_form.xml
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> .... <fieldset name="General"> ... <field name="zip_code" formElement="input"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="inputMask" xsi:type="array"> <!-- pass your simple mask here--> <item name="mask" xsi:type="string">00-000</item> </item> </item> </argument> <settings> <validation> <rule name="required-entry" xsi:type="boolean">true</rule> </validation> <label translate="true">Zip Code</label> <placeholder>00-000</placeholder> </settings> </field> ... </fieldset> </form>
此插件是懒加载 - inputmask.min.js 只在页面中某个字段需要时才加载。