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

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

Open
marvinschroeder opened this issue Mar 4, 2019 · 8 comments
Labels

Comments

@marvinschroeder
Copy link

marvinschroeder commented Mar 4, 2019

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>
@claar
Copy link
Member

claar commented Mar 5, 2019

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

@marvinschroeder
Copy link
Author

marvinschroeder commented Mar 5, 2019

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.

@mrextreme
Copy link

mrextreme commented Mar 15, 2019

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 );

@claar
Copy link
Member

claar commented Mar 15, 2019

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

@mrextreme
Copy link

edited my comment above to be backwards-compatible

@CedNet
Copy link
Contributor

CedNet commented Aug 26, 2019

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.

@claar
Copy link
Member

claar commented Aug 29, 2019

@CedNet Done.

@darrencoutts118
Copy link

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

tortuetorche added a commit to tortuetorche/former that referenced this issue Dec 30, 2020
Usage with Laravel:
{{-- Basic input addon --}}
{!! Former::open()->method('GET') !!}
    {!! Former::text('test2')->append('&euro;') !!}
{!! Former::close() !!}

{{-- Multiple input addons --}}
{!! Former::open()->method('GET') !!}
    {!! Former::text('test3')->append(['&euro;', 'second']) !!}
{!! Former::close() !!}

{{-- Button addon --}}
{!! Former::open()->method('GET') !!}
{!! Former::text('test4')->append('<button class="btn">OK</button>')
!!}
{!! Former::close() !!}

{{-- Button addons --}}
{!! Former::open()->method('GET') !!}
{!! Former::text('test5')->append(['<button
class="btn">OK</button>', '<button class="btn">2</button>']) !!}
{!! Former::close() !!}

Credits: @mrextreme

Reference:
formers#581 (comment)
tortuetorche added a commit to tortuetorche/former that referenced this issue Dec 30, 2020
E.g.
{!! Former::open()->method('GET') !!}
    {!! Former::checkbox('test')->text('Test checkbox') !!}
{!! Former::close() !!}

Render:
<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 checkbox</label>
</div>

References:
- formers#581
- formers#590
tortuetorche added a commit to tortuetorche/former that referenced this issue Dec 30, 2020
E.g. with Laravel:
@php
    $validator = Validator::make(request()->all(), [
        'failed_checkbox' => 'required',
        'failed_radio' => 'required',
        'failed_inline_checkbox' => 'required',
        'failed_inline_radio' => 'required',
        'failed_checkboxes' => 'required',
        'failed_inline_checkboxes' => 'required',
    ]);

    $validator->fails();
    Former::withErrors($validator);
@endphp

{!! Former::open()->method('GET') !!}
    {!! Former::checkbox('failed_checkbox')->text('Failed checkbox') !!}
    {!! Former::radio('failed_radio')->text('Failed radio') !!}
{!! Former::checkbox('failed_inline_checkbox')->text('Failed inline
checkbox')->inline() !!}
{!! Former::radio('failed_inline_radio')->text('Failed inline
radio')->inline() !!}
{!! Former::checkboxes('failed_checkboxes')->checkboxes('first',
'second', 'third', 'fourth') !!}
{!!
Former::checkboxes('failed_inline_checkboxes')->checkboxes('first',
'second', 'third', 'fourth')->inline() !!}
{!! Former::close() !!}

Reference:
formers#581 (comment)
@stayallive stayallive added the Bug label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants