无法在 SFCC Demandware 中保存用户选择的选项列表值

问题描述

我在标准的“个人资料”对象中创建了一个属性(favouriteStore - Enum of String 数据类型),并将其添加到店面的帐户创建页面。现在,我无法将用户选择的选项列表值从 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
        };

profile.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,London EC2 9AW"/>
                <option optionid="3" label="London Store,2nd Street,London  EC2 9AW" value="London Store,London  EC2 9AW"/>
            </options>
            </field>

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

提前致谢!

解决方法

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

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...