jeudi 28 mai 2020

How to make multiple columns of checkboxes with Rails 6, collection_check_boxes and Bootstrap 4?

I'm trying to display a (really) long list of checkboxes in a series of columns instead.

In my form, I'm using

<%= f.collection_check_boxes(:building_ids, Building.all, :id, :option) %>

I tried this solution, but it wasn't responsive and the boxes in the right-hand column were spaced out weird (justified top to bottom).

This Reddit was promising, but unfortunately the OP didn't post his final/working code.

I'm pretty sure I have to add some custom CSS and then wrap the f.collection_check_boxes with it, but I'm not sure how to go about that. Some solutions have done this with a few divs and then styled them with a few custom CSS classes.

Oh, and I'm using the bootstrap_form gem to apply Bootstrap to form elements, but I could probably find a way to apply a more generic Bootstrap solution.




Aucun commentaire:

Enregistrer un commentaire