Bootstrap "multiple" simple_form 的属性
Bootstrap "multiple" attribute for simple_form
我想要一个向下滚动的菜单,其中包含可供选择的不同选项 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: ">Monthly member: </option>
<option value="Pay-Per-Use (cash): 15% discount">Pay-Per-Use (cash): 15% discount</option>
<option value="Youth member: ">Youth member: </option>
<option value="Monthly with children (Friday's): + per child">Monthly with children (Friday's): + per child</option>
<option value="Other - specify in notes">Other - specify in notes</option></select></div>
我需要以某种方式将 multiple
属性插入到 select 标记中。有没有一种技术可以使用嵌入式 Ruby 执行此操作而无需手动编辑 html 代码?
只需将您的代码替换为以下行
<%= f.input :member_type, collection: Form::MEMBERSHIPS, include_blank: true, error: false,:input_html => {:multiple => true} %>
希望我回答了你的问题。
我想要一个向下滚动的菜单,其中包含可供选择的不同选项 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: ">Monthly member: </option>
<option value="Pay-Per-Use (cash): 15% discount">Pay-Per-Use (cash): 15% discount</option>
<option value="Youth member: ">Youth member: </option>
<option value="Monthly with children (Friday's): + per child">Monthly with children (Friday's): + per child</option>
<option value="Other - specify in notes">Other - specify in notes</option></select></div>
我需要以某种方式将 multiple
属性插入到 select 标记中。有没有一种技术可以使用嵌入式 Ruby 执行此操作而无需手动编辑 html 代码?
只需将您的代码替换为以下行
<%= f.input :member_type, collection: Form::MEMBERSHIPS, include_blank: true, error: false,:input_html => {:multiple => true} %>
希望我回答了你的问题。