我正在尝试为在Shopify中注册我的商店的客户分配多个自定义标签。
这是我到目前为止所做的,但它将第一个标签与第二个标签分配,我需要找到一种方法来分配和保留两者。
{% layout settings.customer_layout %}
<div id="customer-accounts" class="content clearfix">
<!-- Create Customer -->
<div id="customer-register">
<div class="page-header">
<h1>Create Account</h1>
</div>
{% form 'create_customer' %}
{{ form.errors | default_errors }}
<div id="school" class="clearfix form-row">
<label for="school">School</label>
<select name="customer[tags]" id="school">
<option value="default" selected="selected">Choose your school</option>
<option value="syracuse">Syracuse</option>
<option value="cornell">Cornell</option>
<option value="Miami">UMiami</option>
</select>
</div>
<div id="fraternity" class="clearfix form-row">
<label for="fraternity">Fraternity</label>
<select name="customer[tags]" id="fraternity">
<option value="default" selected="selected">Choose your fraternity</option>
<option value="sigma_chi">Sigma Chi</option>
<option value="sigma_alpha_mu">Sigma Alpha Mu</option>
<option value="delta_tau_delta">Delta Tau Delta</option>
</select>
</div>
<div id="first_name" class="clearfix form-row">
<label for="first_name" class="login">First Name</label>
<input type="text" value="{{ form.first_name }}" name="customer[first_name]" id="first_name" class="large" size="30" />
</div>
<div id="last_name" class="clearfix form-row">
<label for="last_name" class="login">Last Name</label>
<input type="text" value="{{ form.last_name }}" name="customer[last_name]" id="last_name" class="large{% if form.errors contains 'last_name' %} error{% endif %}" size="30" />
</div>
<div id="email" class="clearfix form-row">
<label for="email" class="login">Email Address</label>
<input type="email" value="{{ form.email }}" name="customer[email]" id="email" class="large{% if form.errors contains 'email' %} error{% endif %}" size="30" />
</div>
<div id="password" class="clearfix form-row">
<label for="password" class="login">Password</label>
<input type="password" value="" name="customer[password]" id="password" class="large password{% if form.errors contains 'password' %} error{% endif %}" size="30" />
</div>
<div class="action_bottom">
<input class="btn" type="submit" value="Create" />
</div>
{% endform %}
答案 0 :(得分:1)
更改表单。对于选择元素id = school和id = fraternity,您不希望使用相同名称customer [tags]。相反,为该命名客户[tags]创建一个新的隐藏元素。在提交表单之前,使用Javascript从id = school和id = fraternity元素中获取值,并将它们组合成一个字符串,用逗号分隔。将该字符串分配给名为customer [tags]的隐藏元素。然后,这将分配两个值。提交那份表格,你就可以了。