Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox not displaying in Bootstrap 5 #1736

Closed
MtnBiker opened this issue May 18, 2021 · 2 comments
Closed

Checkbox not displaying in Bootstrap 5 #1736

MtnBiker opened this issue May 18, 2021 · 2 comments

Comments

@MtnBiker
Copy link

MtnBiker commented May 18, 2021

Checkbox not rendering correctly in Bootstrap 5. I upgraded to v5 to get another feature.

Environment

Current behavior. Extant is a boolean

<%= simple_form_for(@location) do |form| %>
<%= form.input :extant %>

HTML generated

<div class="form-check"><input name="location[extant]" type="hidden" value="0"><input class="form-check-input boolean optional" type="checkbox" value="1" name="location[extant]" id="location_extant"><label class="form-check-label boolean optional" for="location_extant">Extant</label></div>

Screenshot below (the green line is from the text field directly above). The short gray line is the checkbox:
image

Expected behavior

A checkbox.

The short gray line does react when click on and turns blue.

@MtnBiker
Copy link
Author

MtnBiker commented May 18, 2021

I wonder if I have a webpacker problem and the stylesheets aren't getting added. Because if I put

    <div class="form-check form-switch">
      <input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault">
      <label class="form-check-label" for="flexSwitchCheckDefault">Default switch checkbox input</label>
    </div>

in the form just below the original checkbox, I get

image

application.js

import 'bootstrap' // or require("bootstrap"); use import for yarn?

import 'bootstrap/dist/js/bootstrap' // not always done

application.scss

@import "bootstrap/scss/bootstrap";

Sure enough I found the problem:

I also had some custom formatting that was overriding. Haven't sorted out what it is yet, but removing one .scss file fixed the checkbox, but no doubt breaks something else, so need to figure out what class is wrong.

.input has this line and it is the problem. My comments aren't good enough to show why I have it.
height: auto !important;

@carlosantoniodasilva
Copy link
Member

carlosantoniodasilva commented May 18, 2021

Glad to know you've figured it out.

Please note that there's some work being done to get the bootstrap initializer fully working with Simple Form here: heartcombo/simple_form-bootstrap#329 (separate repo for the sample app & bootstrap config development), you might want to keep an eye on that if you're going for v5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants