formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 204 forks source link

Add missing 'form-check-label' class and fix invalid feedback for Bootstrap 4 #601

Closed tortuetorche closed 3 years ago

tortuetorche commented 3 years ago

Add missing form-check-label CSS class for Bootstrap 4

E.g. with Laravel:

{!! 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:


Fix invalid feedback visibility of checkboxes and radios for Bootstrap 4

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() !!}

And here the result: former_checkables_invalid_feedback_bs4

Reference: https://github.com/formers/former/issues/581#issuecomment-469710643