I have two models in many-to-many relationship.
class Rental < ApplicationRecord
has_and_belongs_to_many :features
end
and
class Feature < ApplicationRecord
has_and_belongs_to_many :rentals
end
In my rentals/1/new form I have a field with checkbox collection where user can add features to the rental.
This field works correctly, but the default bootstrap styling is not applied. Basically, wrapper: :vertical_collection_inline doesn't do anything here. It's now one sad vertical checkbox collection.
How can I add styling to this field? I did read https://github.com/heartcombo/simple_form#the-wrappers-api but can't seem to find the answer...I need it to be this way because I need to be able to translate every feature name.
<%= f.input :feature_ids, as: :check_boxes do %>
<%= f.collection_check_boxes :feature_ids, Feature.order(:name), :id, :name, wrapper: :vertical_collection_inline do |b|
b.label { b.check_box + " " + t("#{b.text}") }
end %>
<% end %>
This other solution works and looks good (has the Bootstrap styling applied) but I can't figure out how to translate the feature names on it..
<%= f.input :feature_ids, as: :check_boxes, collection: Feature.all, wrapper: :vertical_collection_inline %>
Seems I only needed to post on here in order to find the answer myself! This works both for style and translation: