繁体   English   中英

Shopware 6 sw-number-field:如何设置id?

[英]Shopware 6 sw-number-field: how to set id?

如何在自定义插件中设置sw-number-field.id

默认情况下, sw-number-field.id的配置设计违规

这可以在产品详细信息页面上的价格字段中观察到:

在此处输入图像描述

// sw-number-field.html.twig

<template #sw-field-input="{ identification, error, disabled, size, setFocusClass, removeFocusClass }">
    <!-- eslint-disable-next-line vuejs-accessibility/form-control-has-label -->
        <input
            :id="identification"

identification来自哪里,或者应该在哪里设置?

您可以使用name属性,它也将替换自动生成的id

<sw-number-field name="foobar" />
<!-- becomes -->
<input id="foobar" name="foobar" type="text" placeholder="" autocomplete="off">

默认设置在src/app/component/form/field-base/sw-base-field/index.js

data() {
    return {
        id: utils.createId(),
    };
},

computed: {
    identification() {
        if (this.name) {
            return this.name;
        }

        return `sw-field--${this.id}`;
    },

    //...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM