0

I would like to have a scroll down menu with different options to choose from using Bootstrap, as demonstrated here:

  <select multiple class="form-control">
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
    </select>

I am currently using simple_form to construct my menu (it is a dropdown menu by default):

<%= f.input :member_type, collection: Form::MEMBERSHIPS, include_blank: true, error: false %>

Which outputs as such:

<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&#39;s): $55 + $16 per child">Monthly with children (Friday&#39;s): $55 + $16 per child</option>
<option value="Other - specify in notes">Other - specify in notes</option></select></div>

I need to somehow insert the multiple attribute into the select tag. Is there a technique to do this using embedded Ruby without having to manually edit the html code?

1 Answer 1

4

Just replace your code with following line

<%= f.input :member_type, collection: Form::MEMBERSHIPS, include_blank: true, error: false,:input_html => {:multiple => true} %> 

Hope I answered your question.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.