0

我在标准“配置文件”对象中创建了一个新属性(favouriteStore - 字符串数据类型的枚举),并将其添加到店面的帐户创建页面。现在,我无法将用户选择的选项列表值从 ISML 获取到 js。我尝试了下面的代码,它返回未定义。你能帮我解决这个问题吗?

下面是 isml 代码:registerForm.isml

 <div class="form-group
        <isif condition=" ${!!pdict.profileForm.customer.favouriteStore.mandatory === true}">required</isif>">

        <label class="form-control-label" for="registration-form-favouriteStore">
            <isprint value="${pdict.profileForm.customer.favouriteStore.label}" encoding="htmlcontent" />
        </label>
        <div class="info-icon">
            <span><i class="fa fa-info-circle beet-color" aria-hidden="true"></i></span>
            <span class="tooltip account-tooltip d-none">Pick your favourite store</span>
        </div>
        <select class="custom-select form-control" id="favouriteStore" onchange="getSelected(this)" name="favouriteStore">
        <isloop items=${pdict.profileForm.customer.favouriteStore.options} var="store">
            <option id="${store.id}" value="${store.htmlValue}" 
            <isif condition="${store.selected}">selected</isif> >${store.label}</option>
        </isloop>
        </select>
    </div>

JS代码:Account.js

var registrationFormObj = {
            firstName: registrationForm.customer.firstname.value,
            lastName: registrationForm.customer.lastname.value,
            phone: registrationForm.customer.phone.value,
            email: registrationForm.customer.email.value,
            emailConfirm: registrationForm.customer.emailconfirm.value,
            password: registrationForm.login.password.value,
            passwordConfirm: registrationForm.login.passwordconfirm.value,
            customerPostcode: registrationForm.customer.customerPostcode.value,
            favouriteStore: registrationForm.customer.favouriteStore.value,
            marketingPreferences: registrationForm.customer.marketingPreferences.value,
            validForm: registrationForm.valid,
            form: registrationForm
        };

配置文件.xml:

<field formid="favouriteStore" label="Favourite Store" type="string" mandatory="true" binding="favouriteStore">
            <options>
                <option optionid="" label="" value=""/>
                <option optionid="1" label="Shell Kingsburn, Borough of Royal Kensington, London EC2 3AH" value="Shell Kingsburn Borough of Royal Kensington, London EC2 3AH"/>
                <option optionid="2" label="Chealsea, City Road, London EC2 9AW" value="Chealsea, City Road, London EC2 9AW"/>
                <option optionid="3" label="London Store, 2nd Street, London  EC2 9AW" value="London Store, 2nd Street, London  EC2 9AW"/>
            </options>
            </field>

所有其他字符串字段都被保存,只是这个 favouriteStore 选项列表字段返回未定义。你能指导我哪里出错了。

提前致谢!

4

1 回答 1

0

正如AlBlue提到的,问题似乎是您favouriteStore在 ISML 和 DWScript 中的拼写方式不同。(JavaScript)

也就是说,您应该确保还为该字段定义了表单 XML。例如,您应该将它添加到您的店面墨盒cartridge/forms/default/profile.xml文件中。(或覆盖来自 的那个app_storefront_base

于 2021-01-07T22:16:29.173 回答