Last active
December 21, 2018 18:01
-
-
Save peterclark/9ba125390b831c206e68ace8f1be1fbb to your computer and use it in GitHub Desktop.
rails collection checkboxes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for has_and_belongs_to_many, required true | |
= f.collection_check_boxes :ethnicity_ids, Ethnicity.all, :id, :name, {}, { required: true } do |e| | |
= e.label do | |
= e.check_box | |
= e.text | |
# or for has_many through with different wrappers | |
= f.collection_check_boxes :health_goal_ids, HealthGoal.ordered, :id, :name, boolean_style: :inline, item_wrapper_tag: nil do |goal| | |
.c-radio.c-radio--square.c-radio--rectangle.c-radio--orange.c-radio--50 | |
= goal.check_box | |
= goal.label do | |
%span= goal.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment