Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Larakit Bootstrap Form Laravel Package

larakit/laravel-larakit-bootstrap-form

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require larakit/laravel-larakit-bootstrap-form
    

    Publish the package assets (if needed):

    php artisan vendor:publish --provider="Larakit\BootstrapForm\BootstrapFormServiceProvider" --tag=public
    
  2. Basic Usage Include the package in your app.blade.php or layout:

    {!! Form::open(['url' => '/submit']) !!}
        {!! Form::text('username', null, ['placeholder' => 'Username']) !!}
        {!! Form::submit('Submit') !!}
    {!! Form::close() !!}
    
  3. First Use Case Replace a standard Blade form with Bootstrap-styled inputs:

    @form(['url' => '/profile', 'method' => 'PUT'])
        @text('name', null, ['placeholder' => 'Full Name'])
        @select('country', ['US' => 'USA', 'CA' => 'Canada'], 'US')
        @submit('Update Profile')
    @endform
    

Implementation Patterns

Common Workflows

  1. Form Generation Use @form directive for opening forms with Bootstrap classes:

    @form(['url' => '/contact', 'class' => 'form-horizontal'])
        @text('email', null, ['class' => 'form-control'])
        @textarea('message', null, ['rows' => 5, 'class' => 'form-control'])
    @endform
    
  2. Field-Specific Styling Leverage built-in helpers for common input types:

    @checkbox('subscribe', true, ['label' => 'Subscribe to Newsletter'])
    @radio('gender', 'male', ['label' => 'Male', 'labelClass' => 'radio-inline'])
    @date('birthday', null, ['class' => 'form-control datepicker'])
    
  3. Validation Integration Combine with Laravel validation and display errors:

    @text('email', $errors->first('email'), ['class' => 'form-control', 'placeholder' => 'Email'])
    @if($errors->has('email'))
        <div class="alert alert-danger">{{ $errors->first('email') }}</div>
    @endif
    
  4. Dynamic Forms Use Blade loops for dynamic fields:

    @foreach($items as $item)
        @text("item[{$loop->index}][name]", $item->name, ['class' => 'form-control'])
    @endforeach
    

Integration Tips

  • Asset Management: Ensure Bootstrap CSS/JS is loaded before the form package.
  • Customization: Override default classes via config (config/bootstrap-form.php).
  • Localization: Extend with custom translations for labels/placeholders.

Gotchas and Tips

Pitfalls

  1. Missing Assets Forgetting to publish assets or load Bootstrap JS/CSS will break form functionality (e.g., dropdowns, tooltips). Fix: Run php artisan vendor:publish --tag=public and include:

    <link href="{{ asset('vendor/bootstrap-form/css/bootstrap-form.css') }}" rel="stylesheet">
    
  2. Form Method Spoofing Omitting method in @form defaults to GET, which may cause issues with PATCH/PUT. Fix: Always specify the method:

    @form(['url' => '/post', 'method' => 'POST'])
    
  3. CSRF Token Conflicts If using @form without csrf field, manually add:

    @form(['url' => '/post', 'csrf' => true])
    

Debugging

  • Field Naming: Use {{ Form::getFieldName('field') }} to debug generated names (e.g., nested arrays).
  • Class Overrides: Check config/bootstrap-form.php for conflicting class names.

Extension Points

  1. Custom Helpers Extend the package by creating a macro:

    Form::macro('customInput', function ($name, $value, $options) {
        return '<input type="custom" name="' . e($name) . '" value="' . e($value) . '" ' . e($options) . '>';
    });
    
  2. Dynamic Attributes Use Form::attributes() to merge dynamic classes:

    @text('field', null, Form::attributes(['class' => 'form-control', 'data-toggle' => 'tooltip']))
    
  3. Event Listeners Hook into form events via the BootstrapForm facade:

    \BootstrapForm::listen('beforeRender', function ($form) {
        $form->addClass('my-custom-form');
    });
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware