former icon indicating copy to clipboard operation
former copied to clipboard

Bootstrap 4 Framework uses wrong classes for input group & no classes for checkbox

Open marvinschroeder opened this issue 5 years ago • 8 comments

There were currently two bugs with the Bootstrap 4 framework. Tested in Bootstrap v4.1.3 and v4.3.1 (latest) and used in Laravel 5.7.*

Input Group with Append

Problem: appended/prepended text is not displaying correctly because of wrong class "input-group-addon".

Line used:

Former::text('test')->append('€');

Renders:

<div class="form-group">
 <div class="input-group">
  <input class="form-control" id="test" type="text" name="test">
  <span class="input-group-addon">€</span>
 </div>
</div>

Expected:

<div class="form-group">
  <div class="input-group">
    <input class="form-control" id="test" type="text" name="test">
    <div class="input-group-append">
      <span class="input-group-text">€</span>
    </div>
  </div>
</div>

Checkbox

Problem: small displaying tweaks because of missing classes for input and label.

Line used:

Former::checkbox('test')->text('Test');

Renders:

<div class="form-group">
  <div class="form-check">
    <input id="test" type="checkbox" name="test" value="1">
    <label for="test" class="">Test</label>
  </div>
</div>

Expected:

<div class="form-group">
  <div class="form-check">
    <input class="form-check-input" id="test" type="checkbox" name="test" value="1">
    <label for="test" class="form-check-label">Test</label>
  </div>
</div>

marvinschroeder avatar Mar 04 '19 21:03 marvinschroeder

Thanks so much! Any chance you'd be willing to submit a PR?

claar avatar Mar 05 '19 01:03 claar

Unfortunately, I currently do not have the time to submit a PR. In the meantime i found another bug with the Bootstrap 4 checkbox:

Line used:

Former::checkbox('test')->text('Test');

Rendered with invalid feedback:

<div class="form-group is-invalid">
  <div class="form-check">
    <input id="test" type="checkbox" name="test" value="1">
    <label for="test" class="">Test</label>
  </div>
  <div class="invalid-feedback">Error message.</div>
</div>

Expected with invalid feedback:

<div class="form-group is-invalid">
  <div class="form-check">
    <input class="form-check-input" id="test" type="checkbox" name="test" value="1">
    <label for="test" class="form-check-label">Test</label>
    <div class="invalid-feedback">Error message.</div>
  </div>
</div>

Solution: place .valid-/.invalid-feedback inside .form-check to actually display the feedback message.

marvinschroeder avatar Mar 05 '19 14:03 marvinschroeder

I ran into the same issue. Hacked the code, it works nicely so i can continue developing our app while this gets fixed the proper way, and released.

in Former/Form/Group.php, find protected function placeAround($items, $place) at the bottom of the file, and replace this line $item = $this->app['former.framework']->placeAround($item); with this $item = $this->app['former.framework']->placeAround($item, $place);

in Former/Framework/TwitterBootstrap4.php, find public function placeAround($item) and replace it with public function placeAround($item, $place=null) and the last line of the function return Element::create( ... with return Element::create('div', "<div class=\"input-group-text\">{$item}</div>")->addClass('input-group-'.$place);

edit: actually, it should be addClass( 'input-group-' . $place ?? $class );

mrextreme avatar Mar 15 '19 10:03 mrextreme

Thanks, @mrextreme ! Now we just need someone to package up the above into a PR with tests -- any takers?

claar avatar Mar 15 '19 19:03 claar

edited my comment above to be backwards-compatible

mrextreme avatar Mar 19 '19 09:03 mrextreme

Can I please ask that you merge my PR to fix the issue with the wrong class for checkboxes and radios?

Fine if the code is altered. Just need the checkbox styling to work properly for Bootstrap 4.

CedNet avatar Aug 26 '19 08:08 CedNet

@CedNet Done.

claar avatar Aug 29 '19 13:08 claar

Has there been any movement on getting a PR together for fixing this?

darrencoutts118 avatar Dec 04 '20 09:12 darrencoutts118