多重选择框在导轨中不起作用 [英] Multiple select box is not working in rails
本文介绍了多重选择框在导轨中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码选择多个值.
I am using the following code to select multiple values.
<select name="video" multiple="multiple" id="form-field-select-2" class="form-control">
<%video.each do |option|%>
<option><%=option%> </option>
<%end%>
</select>
但是在提交表单后,它没有给出所有选定的值,而不是仅给出最后一个选定的值.
But after submitting form its not giving all selected values,instead of its giving only the last selected value.
如果对这个问题有任何想法,请分享.
Please share if you have any idea about this issue.
推荐答案
<select name="video[]" multiple="multiple" id="form-field-select-2" class="form-control">
<%video.each do |option|%>
<option><%=option%> </option>
<%end%>
</select>
您需要通过将名称更改为video[]
You need to make sure that you are sending an array of answers by changing the name to video[]
这篇关于多重选择框在导轨中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文