如何在div中包装两个结帐表单元素?
例如,假设我想将这些国家/地区和邮政编码/邮政编码字段包装在类别为的div中,该example-class
怎么做?
我尝试过的
我试图通过将它们添加为的子代来实现这一点,<item name="shippingAddress" xsi:type="array">
但这只会在前端导致错误。尽管我确实得到了一个空白文本输入,里面没有标签.example-class
,但是前端还是有错误。
错误: Cannot read property 'indexedOptions' of undefined
这是我的快速尝试:
Magento_Checkout / web / template / shipping-address / form.html
<div id="shipping-new-address-form" class="fieldset address">
<div class="testing">
<!-- ko foreach: getRegion('example-class') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<!-- ko foreach: getRegion('additional-fieldsets') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
checkout_index_index.xml
<item name="example-for-adding-class" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="config" xsi:type="array">
<item name="deps" xsi:type="array">
<item name="0" xsi:type="string">checkoutProvider</item>
</item>
</item>
<item name="displayArea" xsi:type="string">example-class</item>
<item name="children" xsi:type="array">
<!-- The following items override configuration of corresponding address attributes -->
<item name="region" xsi:type="array">
<!-- Make region attribute invisible on frontend. Corresponding input element is created by region_id field -->
<item name="visible" xsi:type="boolean">false</item>
</item>
<item name="region_id" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/region</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/select</item>
<item name="customEntry" xsi:type="string">shippingAddress.region</item>
</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<!-- Value of region_id field is filtered by the value of county_id attribute -->
<item name="filterBy" xsi:type="array">
<item name="target" xsi:type="string"><![CDATA[${ $.provider }:${ $.parentScope }.country_id]]></item>
<item name="field" xsi:type="string">country_id</item>
</item>
</item>
<item name="postcode" xsi:type="array">
<!-- post-code field has custom UI component -->
<item name="component" xsi:type="string">Magento_Ui/js/form/element/post-code</item>
<item name="sortOrder" xsi:type="string">2</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="string">true</item>
</item>
</item>
<item name="country_id" xsi:type="array">
<item name="sortOrder" xsi:type="string">1</item>
</item>
</item>
</item>
必须有一种更简单的方法来执行此操作,或者我丢失了某些东西,或者这是过度工程的定义。在两个元素上添加一个div绝对不会如此困难。