kristijanhusak / laravel-form-builder

Laravel Form builder for version 5+!
https://packagist.org/packages/kris/laravel-form-builder
MIT License
1.69k stars 298 forks source link

Update for Bootstrap 4 #502

Open mikeerickson opened 5 years ago

mikeerickson commented 5 years ago

The current version only supports Bootstrap 3. With Bootstrap 4 the de facto and latest release, this package will be enhanced to provide Bootstrap 4 support

AdamKyle commented 5 years ago

Actually they dont need to update for bootstrap 4, see the field basics. You can just replace those classes with any different bootstrap 4 classes.

And it works.

mikeerickson commented 5 years ago

@AdamKyle OK, I see what you are referencing here. My position is, we want to support Bootstrap 4 out of the box, as default. This will not affect existing users who have already published preferences as the publishing process will NOT overwrite existing users config.

mikeerickson commented 5 years ago

@AdamKyle Further, I am thinking outside the "box" here and trying to create an interface whereby we can support other CSS frameworks (ie Bulma, SemanticUI, etc.) Personally, I tend to use Bulma first as I am looking for something different than the mass amount of Bootstrap looking apps.

ycs77 commented 5 years ago

I provide a Bootstrap 4 template: https://github.com/ycs77/laravel-form-builder-bs4 Used after installation & publish. (If add --force attribute for publishing, will overwrite the Laravel form builder's original config and views)

kristijanhusak commented 5 years ago

Link added to Readme https://github.com/kristijanhusak/laravel-form-builder#bootstrap-4-support. Thanks @ycs77 .

ycs77 commented 5 years ago

Your welcome!

MichaelVoelkel commented 5 years ago

@ycs77 This does not seem to work. We have added this package and use Bootstrap 4 but using the "horizontal" update will still render all the radio buttons vertically to their label which looks really bad. In fact, if you look up the Bootstrap code at https://getbootstrap.com/docs/4.0/components/forms/ , it seems that you need to use form-check which is not apparent in the source code at all. And the files of your repository do not update these code parts anyways, as it seems. Any help?

ycs77 commented 5 years ago

Hi @Elypson

Because the publish preset does not overwrite existing files, you can run php artisan vendor:publish --tag=laravel-form-builder-bs4-horizontal --force to force override Laravel form builder's config and views. Although you can switch to horizontal mode, BUT, the original Laravel form builder's config and views in your repository CAN NOT be retrieved. Please think twice.

And I use custom-control instead of form-check. If you are used form-check, you can modify the config after publishing.

MichaelVoelkel commented 5 years ago

@ycs77 Okay, I frankly do not see any benefit of your repository and we have removed this from our project. But maybe I overlook something, maybe you could describe your repository's benefit more clearly in your README.md.

What works is to attach the corresponding CSS classes to @kristijanhusak's form. Our main issue lied in choice and this can be fixed with:

$choiceOptions = [
        'wrapper' => ['class' => 'form-check'],
        'label_attr' => ['class' => 'form-check-label'],
        'attr' => ['class' => 'form-check-input']
    ];

When adding a choice, use e.g.:

->add('name', 'choice', ['choice_options' => $choiceOptions]);

Now, everything is fine with @kristijanhusak's repository alone