Skip to content

Instantly share code, notes, and snippets.

@aghuddleston
Last active June 8, 2016 18:12
Show Gist options
  • Save aghuddleston/b6ee3944fb7aca0bafaf139d13467b87 to your computer and use it in GitHub Desktop.
Save aghuddleston/b6ee3944fb7aca0bafaf139d13467b87 to your computer and use it in GitHub Desktop.
SimpleForm (and Ransack) with Bootstrap 3, needing "checkbox-inline" style without the extra "label" field that simple-form seems to like to generate. Manually adding the collection wrapper div.
= search_form_for @q, url: my_path, html: {method: :get} do |f|
.row
.col-md-4
.form-group
%label.string.required.control-label= "Years Teaching"
.row-link
= f.collection_check_boxes :contact_info_profile_teaching_history_subject_taughts_years_teaching_in, TeachYears.all, :id, :name, {item_label_class: "checkbox-inline", item_wrapper_tag: false, boolean_style: :inline } do |b|
- b.label(class: "checkbox-inline") { b.check_box + b.text}
<div class="col-md-4 ">
<div class="form-group">
<label class="string required control-label">Years Teaching</label>
<div class="row-link">
<label class="checkbox-inline" for="q_contact_info_profile_teaching_history_subject_taughts_years_teaching_in_1-5_years">
<input type="checkbox" value="1-5 years" name="q[contact_info_profile_teaching_history_subject_taughts_years_teaching_in][]" id="q_contact_info_profile_teaching_history_subject_taughts_years_teaching_in_1-5_years">1-5 years
</label>
<label class="checkbox-inline" for="q_contact_info_profile_teaching_history_subject_taughts_years_teaching_in_6-10_years">
<input type="checkbox" value="6-10 years" name="q[contact_info_profile_teaching_history_subject_taughts_years_teaching_in][]" id="q_contact_info_profile_teaching_history_subject_taughts_years_teaching_in_6-10_years">6-10 years
</label>
<label class="checkbox-inline" for="q_contact_info_profile_teaching_history_subject_taughts_years_teaching_in_over_10_years">
<input type="checkbox" value="over 10 years" name="q[contact_info_profile_teaching_history_subject_taughts_years_teaching_in][]" id="q_contact_info_profile_teaching_history_subject_taughts_years_teaching_in_over_10_years">over 10 years
</label>
<input type="hidden" name="q[contact_info_profile_teaching_history_subject_taughts_years_teaching_in][]" value="">
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment