我想有一个向下滚动菜单,其中有不同的选项可供选择使用Bootstrap,如演示here:
<select multiple class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
我目前正在使用simple_form来构建我的菜单(默认情况下是一个下拉菜单):
<%= f.input :member_type, collection: Form::MEMBERSHIPS, include_blank: true, error: false %>
这样的输出:
<div class="form-group select required form_member_type"><label class="select required control-label" for="form_member_type"><abbr title="required">*</abbr> Member type</label><select class="select required form-control" name="form[member_type]" id="form_member_type"><option value=""></option>
<option value="Monthly member: $55">Monthly member: $55</option>
<option value="Pay-Per-Use (cash): 15% discount">Pay-Per-Use (cash): 15% discount</option>
<option value="Youth member: $35">Youth member: $35</option>
<option value="Monthly with children (Friday's): $55 + $16 per child">Monthly with children (Friday's): $55 + $16 per child</option>
<option value="Other - specify in notes">Other - specify in notes</option></select></div>
我需要以某种方式将multiple
属性插入到select标记中。是否有使用嵌入式Ruby的技术,而无需手动编辑html代码?
答案 0 :(得分:4)
只需用以下行替换您的代码
<%= f.input :member_type, collection: Form::MEMBERSHIPS, include_blank: true, error: false,:input_html => {:multiple => true} %>
希望我回答你的问题。