PHPackages                             fey/laravel-bootstrap-4-forms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. fey/laravel-bootstrap-4-forms

ActivePackage[Templating &amp; Views](/categories/templating)

fey/laravel-bootstrap-4-forms
=============================

Bootstrap 4 form builder for Laravel 5

3.0.4(6y ago)04MITPHP

Since Mar 28Pushed 6y agoCompare

[ Source](https://github.com/fey/laravel-bootstrap-4-forms)[ Packagist](https://packagist.org/packages/fey/laravel-bootstrap-4-forms)[ RSS](/packages/fey-laravel-bootstrap-4-forms/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (16)Used By (0)

Bootstrap 4 forms for Laravel 7
===============================

[](#bootstrap-4-forms-for-laravel-7)

[![Latest Version on Packagist](https://camo.githubusercontent.com/23949bd461bac4ba1d364f43dfd0798aa6cb6018f109726cc00080e3d086c680/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6665792f6c61726176656c2d626f6f7473747261702d342d666f726d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fey/laravel-bootstrap-4-forms)[![Total Downloads](https://camo.githubusercontent.com/7879e9a9319a9e2fc3aab053d79ae79f4a2f9709bd37446ed25d396335fd110f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6665792f6c61726176656c2d626f6f7473747261702d342d666f726d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fey/laravel-bootstrap-4-forms)

This is a package for creating Bootstrap 4 styled form elements in Laravel 5/6.

Features
--------

[](#features)

- Labels
- Error messages
- Bootstrap 4 markup and classes (including state, colors, and sizes)
- Error validation messages
- Form fill (using Model instance, array or after form submission when a validation error occurs)
- Internationalization
- Add parameters using php chaining approach
- Zero dependences (no Laravel Collective dependency)

Introduction
------------

[](#introduction)

### Before

[](#before)

```

    Username

    @if($errors->has('username'))
    {{$errors->first('username')}}
    @endif

```

### After

[](#after)

```
Form::text('username', 'Username')
```

Installation
------------

[](#installation)

#### Require the package using Composer.

[](#require-the-package-using-composer)

```
composer require netojose/laravel-bootstrap-4-forms
```

### Laravel 5.5 or above

[](#laravel-55-or-above)

If you is using Laravel 5.5, the auto discovery feature will make everything for you and your job is done, you can start using now. Else, follow the steps below to install.

### Laravel 5.4

[](#laravel-54)

#### Add the service provider to your config/app.php file

[](#add-the-service-provider-to-your-configappphp-file)

```
'providers' => [
    //...
	NetoJose\Bootstrap4Forms\Bootstrap4FormsServiceProvider::class,
],
```

#### Add the BootForm facade to the aliases array in config/app.php:

[](#add-the-bootform-facade-to-the-aliases-array-in-configappphp)

```
'aliases' => [
    //...
    'Form' => NetoJose\Bootstrap4Forms\Bootstrap4FormsFacade::class,
],
```

Usage
-----

[](#usage)

### Basic form controls

[](#basic-form-controls)

#### Opening and closing a form

[](#opening-and-closing-a-form)

```
// Opening a form using POST method

{!!Form::open()!!}
// ... Form components here
{!!Form::close()!!}
```

> Opening the form will add \_token field automatically for you

#### Inline form

[](#inline-form)

```
// Making all inputs inline
{!!Form::open()->formInline()!!}

// You can use FALSE to turn off disable form inline
{!!Form::open()->formInline(false)!!}
```

#### Fieldset

[](#fieldset)

ParamTypeDefaultDescription$legendstringnullFieldset Legend```
// Example
{!!Form::fieldsetOpen('Legend title')!!}
// ... fieldset content
{!!Form::fieldsetClose()!!}
```

### Basic inputs

[](#basic-inputs)

#### Text inputs

[](#text-inputs)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$defaultstringnullDefault value```
// Example
{!!Form::text('name', 'User name')!!}
```

##### Textarea

[](#textarea)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$defaultstringnullDefault value```
// Example
{!!Form::textarea('description', 'Description')!!}
```

##### Select

[](#select)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$optionsarray\[\]Select options$defaultstringnullDefault value```
// Example
{!!Form::select('city', 'Choose your city', [1 => 'Gotham City', 2 => 'Springfield'])!!}
```

##### Options

[](#options)

ParamTypeDefaultDescription$optionsiterable\[\]Options list$valueKeystringnullkey for value$idKeystringnullkey for id```
// Example

// With array
{!!Form::select('city', 'Choose your city')->options([1 => 'Gotham City', 2 => 'Springfield'])!!}

// With collection
$cities = collect([1 => 'Gotham City', 2 => 'Springfield'])
{!!Form::select('city', 'Choose your city')->options($cities)!!}

// With model collection
$cities = \App\City::all();
{!!Form::select('city', 'Choose your city')->options($cities)!!}

// Your model should have id and name attributes. If these keys are different, you can pass second and/or third parameters (you can use the second parameter to access some model acessor, also)
$cities = \App\City::all();
{!!Form::select('city', 'Choose your city')->options($cities, 'city_name', 'id_object_field')!!}

// When you are using collections, you can use prepend method (https://laravel.com/docs/5.8/collections#method-prepend) to add an first empty value, like "Choose your city"
$cities = \App\City::all();
{!!Form::select('city', 'Choose your city')->options($cities->prepend('Choose your city', ''))!!}
```

##### Checkbox

[](#checkbox)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$valuestringnullInput value$checkedbooleannullDefault value```
// Example
{!!Form::checkbox('orange', 'Orange')!!}
```

##### Radio

[](#radio)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$valuestringnullInput value$checkedbooleannullDefault value```
// Example
{!!Form::radio('orange', 'Orange')!!}
```

##### File

[](#file)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label```
// Example
{!!Form::file('doc', 'Document')!!}
```

#### Date inputs

[](#date-inputs)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$defaultstringnullDefault value```
// Example
{!!Form::date('birthday', 'Birthday')!!}
```

#### Tel inputs

[](#tel-inputs)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$defaultstringnullDefault value```
// Example
{!!Form::tel('number', 'Phone number')!!}
```

#### Time inputs

[](#time-inputs)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$defaultstringnullDefault value```
// Example
{!!Form::time('hour', 'Meeting hour')!!}
```

#### Time inputs

[](#time-inputs-1)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$defaultstringnullDefault value```
// Example
{!!Form::urlInput('website', 'You website')!!}
```

#### Range inputs

[](#range-inputs)

ParamTypeDefaultDescription$namestringnullInput name$labelstringnullInput label$defaultstringnullDefault value```
// Example
{!!Form::range('name', 'User name')!!}
```

##### Hidden

[](#hidden)

ParamTypeDefaultDescription$namestringnullInput name$defaultbooleannullDefault value```
// Example
{!!Form::hidden('user_id')!!}
```

##### Anchor

[](#anchor)

ParamTypeDefaultDescription$valuestringnullAnchor text$urlstringnullAnchor url```
// Example
{!!Form::anchor("Link via parameter", 'foo/bar')!!}
```

##### Buttons

[](#buttons)

ParamTypeDefaultDescription$valuestringnullButton value$colorstringnullButton color$sizestringnullbutton size###### Submit

[](#submit)

```
// Example
{!!Form::submit("Send form")!!}
```

###### Button

[](#button)

```
// Example
{!!Form::button("Do something", "warning", "lg")!!}
```

###### Reset

[](#reset)

```
// Example
{!!Form::reset("Clear form")!!}
```

### Chainable methods

[](#chainable-methods)

> This package uses [chaining](https://en.wikipedia.org/wiki/Method_chaining) feature, allowing easly pass more parameters.

### Filling a form

[](#filling-a-form)

ParamTypeDefaultDescription$dataobject/arrayarrayData fo fill form inputs```
// Examples

// With initial data using a Model instance
$user = User::find(1);
{!!Form::open()->fill($user)!!}

// With initial array data
$user = ['name' => 'Jesus', 'age' => 33];
{!!Form::open()->fill($user)!!}
```

### Url

[](#url)

Use in anchors and forms openings

ParamTypeDefaultDescription$urlstringnullUrl```
// Example
{!!Form::anchor("Link via url")->url('foo/bar')!!}
```

### Route

[](#route)

Use in anchors and forms openings

ParamTypeDefaultDescription$routestringnullRoute name```
// Example
{!!Form::anchor("Link via route")->route('home')!!}
```

### Error Bag

[](#error-bag)

Use if you have more then one form per page. You set an identifier for each form, and the errors will be attached for that specific form

ParamTypeDefaultDescription$valuestringnullError bag name```
// Example: attach this form to a error bag called "registerErrorBag"
{!!Form::open()->route('register.post')->errorBag("registerErrorBag")!!}

// ------------------------------------------------------

// Now, in your controller (register.post route), you can redirect the user to a form page again, with erros inside a error bag called "registerErrorBag"
public function register(Request $request)
{
    $validator = Validator::make($request->all(), [
        // ... rules here
    ]);

    if ($validator->fails()) {
        return redirect()
            ->route('register.form')
            ->withInput()
            ->withErrors($validator, 'registerErrorBag');
    }

    // Proced to register here
}

// ------------------------------------------------------

// If your validation is on a Form Request, you can add a protected method "$errorBag" to set a ErrorBag name

class RegisterRequest extends FormRequest
{

    protected $errorBag = 'registerErrorBag';

    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            // ... rules here
        ];
    }
}
```

### Errors

[](#errors)

Show all errors inside a panel

ParamTypeDefaultDescription$titlestringnullPanel title```
// Example
{!!Form::errors("The form has errors")!!}
```

### Disable validation messages

[](#disable-validation-messages)

Disable success/error status and validation error message

ParamTypeDefaultDescription$disabledbooleanfalseDisabled status```
// Example
{!!Form::text('username', 'User name')->disableValidation()!!}

// You can use FALSE to turn off disable validation (to enable it)
{!!Form::text('username', 'User name')->disableValidation(false)!!}
```

### Checked

[](#checked)

Set the checkbox/radio checked status

ParamTypeDefaultDescription$checkedbooleantrueChecked status```
// Examples

// Using readonly field
{!!Form::checkbox('agree', 'I agree')->checked()!!}

// You can use FALSE to turn off checked status
{!!Form::checkbox('agree', 'I agree')->checked(false)!!}
```

### Inline

[](#inline)

Set the checkbox/radio checked status

```
// Examples
{!!Form::radio('orange', 'Orange')->inline()!!}

{!!Form::checkbox('orange', 'Orange')->inline()!!}

// You can use FALSE to turn off inline status
{!!Form::checkbox('orange', 'Orange')->inline(false)!!}
```

### Placeholder

[](#placeholder)

ParamTypeDefaultDescription$placeholderstringnullPlaceholder text```
// Example
{!!Form::text('name', 'Name')->placeholder('Input placeholder')!!}
```

### Select Multiple

[](#select-multiple)

```
// Example
{!!Form::select('city', 'Choose your city', [1 => 'Gotham City', 2 => 'Springfield'])->multiple()!!}
```

### Locale

[](#locale)

Using locale, the package will look for a resources/lang/{CURRENT\_LANG}/forms/user.php language file and uses labels and help texts as keys for replace texts

```
// Example
{!!Form::open()->locale('forms.user')!!}
```

### Help Text

[](#help-text)

ParamTypeDefaultDescription$textstringnullHelp text```
// Example
{!!Form::text('name', 'Name')->help('Help text here')!!}
```

### Custom attributes

[](#custom-attributes)

ParamTypeDefaultDescription$attrsarray\[\]Custom input attributes```
// Example
{!!Form::text('name', 'Name')->attrs(['data-foo' => 'bar', 'rel'=> 'baz'])!!}
```

### Custom attributes in wrapper div (&lt;div class="form-group"&gt;...&lt;/div&gt;)

[](#custom-attributes-in-wrapper-div-div-classform-groupdiv)

ParamTypeDefaultDescription$attrsarray\[\]Custom input attributes```
// Example
{!!Form::text('name', 'Name')->wrapperAttrs(['data-foo' => 'bar', 'id'=> 'name-wrapper'])!!}
```

### Readonly

[](#readonly)

ParamTypeDefaultDescription$statusbooleantrueRead only status```
// Examples

// Using readonly field
{!!Form::text('name', 'Name')->readonly()!!}

// You can use FALSE to turn off readonly status
{!!Form::text('name', 'Name')->readonly(false)!!}
```

### Disabled

[](#disabled)

ParamTypeDefaultDescription$statusbooleantrueDisabled status```
// Examples

// Disabling a field
{!!Form::text('name', 'Name')->disabled()!!}

// Disabling a fieldset
{!!Form::fieldsetOpen('User data')->disabled()!!}

// You can use FALSE to turn off disabled status
{!!Form::text('name', 'Name')->disabled(false)!!}
```

### Block

[](#block)

ParamTypeDefaultDescription$statusbooleantrueDisabled status```
// Examples

// Disabling a field
{!!Form::text('name', 'Name')->block()!!}

// You can use FALSE to turn off block status
{!!Form::text('name', 'Name')->block(false)!!}
```

### Required

[](#required)

ParamTypeDefaultDescription$statusbooleantrueRequired status```
// Examples

// Disabling a field
{!!Form::text('name', 'Name')->required()!!}

// Disabling a fieldset
{!!Form::fieldsetOpen('User data')->required()!!}

// You can use FALSE to turn off required status
{!!Form::text('name', 'Name')->required(false)!!}
```

### AutoFill

[](#autofill)

ParamTypeDefaultDescription$valuestring'on'autocomplte valuesee:

If no autocomplete value is specified on the form, html spec requires a default value of 'on'. So, you must explicitly turn it off.

Autocomplete values will be automatically generated for fields with single word names matching valid values (e.g. name, email, tel, organization). The complete list is in the spec mentioned above.

```
// Examples

// Switch off autocomplete for the form
{!!Form::open()->autocomplete('off')!!}

// Explicitly set a autocomplete value
{!!Form::text('mobile', 'Mobile Number')->autocomplete('tel')!!}

// Disable autocomplete for fields with valid names
{!!Form::text('name', 'Name')->autocomplete('off')!!}
```

### Id

[](#id)

ParamTypeDefaultDescription$idstringnullId field```
// Example
{!!Form::text('name', 'Name')->id('user-name')!!}
```

### Id prefix

[](#id-prefix)

ParamTypeDefaultDescription$prefixstringnullId prefix```
// Example
{!!Form::open()->idPrefix('register')!!}
```

### Multipart

[](#multipart)

ParamTypeDefaultDescription$multipartbooleantrueMultipart flag```
// Examples
{!!Form::open()->multipart()!!}

// You can use FALSE to turn off multipart
{!!Form::open()->multipart(false)!!}
```

### Method

[](#method)

ParamTypeDefaultDescription$methodstringnullHTTP method```
// Examples
{!!Form::open()->method('get')!!}
{!!Form::open()->method('post')!!}
{!!Form::open()->method('put')!!}
{!!Form::open()->method('patch')!!}
{!!Form::open()->method('delete')!!}
```

### explicit HTTP verbs

[](#explicit-http-verbs)

```
// Examples
{!!Form::open()->get()!!}
{!!Form::open()->post()!!}
{!!Form::open()->put()!!}
{!!Form::open()->patch()!!}
{!!Form::open()->delete()!!}
```

### Color

[](#color)

ParamTypeDefaultDescription$colorstringnullColor name```
// Examples
{!!Form::button("Do something")->color("warning")!!}

{!!Form::button("Do something")->color("primary")!!}
```

### explicit color

[](#explicit-color)

```
// Examples
{!!Form::button("Button label")->warning()!!}
{!!Form::button("Button label")->outline()!!}
{!!Form::button("Button label")->success()!!
{!!Form::button("Button label")->danger()!!}
{!!Form::button("Button label")->secondary()!!}
{!!Form::button("Button label")->info()!!}
{!!Form::button("Button label")->light()!!}
{!!Form::button("Button label")->dark()!!}
{!!Form::button("Button label")->link()!!}
```

### Size

[](#size)

ParamTypeDefaultDescription$sizestringnullSize name```
// Examples
{!!Form::button("Do something")->size("sm")!!}

{!!Form::button("Do something")->size("lg")!!}
```

### Explicit size

[](#explicit-size)

```
// Examples
{!!Form::button("Button label")->sm()!!}
{!!Form::button("Button label")->lg()!!}
```

### Type

[](#type)

ParamTypeDefaultDescription$typestringnullType field```
// Examples

// Password field
{!!Form::text('password', 'Your password')->type('password')!!}

// Number field
{!!Form::text('age', 'Your age')->type('number')!!}

// Email field
{!!Form::text('email', 'Your email')->type('email')!!}
```

### Min

[](#min)

ParamTypeDefaultDescription$valuenumbernullMinimum valueSet min attribute for input

```
// Example
{!!Form::text('age', 'Your age')->type('number')->min(18)!!}
```

### Max

[](#max)

ParamTypeDefaultDescription$valuenumbernullMinimum valueSet max attribute for input

```
// Example
{!!Form::text('age', 'Your age')->type('number')->max(18)!!}
```

### Name

[](#name)

ParamTypeDefaultDescription$namestringnullInput name```
// Examples
{!!Form::text('text')->name('name')!!}
```

### Label

[](#label)

ParamTypeDefaultDescription$labelstringnullInput label```
// Examples
{!!Form::text('age')->label('Your age')!!}
```

### Default Value

[](#default-value)

ParamTypeDefaultDescription$valuemixednullInput value```
// Example
{!!Form::text('name', 'Your name')->value('Maria')!!}
```

### Render

[](#render)

ParamTypeDefaultDescription$renderstringnullRender name```
// Examples

// Number field
{!!Form::render('text')->name('age')->label('Your age')!!}
```

### Disable is-valid CSS Class

[](#disable-is-valid-css-class)

ParamTypeDefaultDescription$disableIsValidbooleantrueDisable is-valid CSS class```
// Examples

// Disable Bootstrap's is-valid CSS class
{!!Form::text('name', 'Name')->disableIsValid()!!}
```

### Chaining properties

[](#chaining-properties)

You can use chaining feature to use a lot of settings for each component

```
// Examples

{!!Form::open()->locale('forms.user')->put()->multipart()->route('user.add')->data($user)!!}

{!!Form::text('name', 'Name')->placeholder('Type your name')->lg()!!}

{!!Form::anchor("Link as a button")->sm()->info()->outline()!!}

{!!Form::submit('Awesome button')->id('my-btn')->disabled()->danger()->lg()!!}

{!!Form::close()!!}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 62.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Recently: every ~8 days

Total

14

Last Release

2481d ago

Major Versions

1.0.1.x-dev → 2.0.02018-06-07

2.0.6 → 3.0.02019-06-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/579c9599e8340e2acd78fb9b1d42b1ee53e828291a8e8d740f4aa1b35d0feae2?d=identicon)[fey](/maintainers/fey)

---

Top Contributors

[![netojose](https://avatars.githubusercontent.com/u/134008?v=4)](https://github.com/netojose "netojose (120 commits)")[![innovaweb-dev](https://avatars.githubusercontent.com/u/2601347?v=4)](https://github.com/innovaweb-dev "innovaweb-dev (15 commits)")[![joseneto-fixeads](https://avatars.githubusercontent.com/u/31626384?v=4)](https://github.com/joseneto-fixeads "joseneto-fixeads (13 commits)")[![snickbit](https://avatars.githubusercontent.com/u/5545229?v=4)](https://github.com/snickbit "snickbit (11 commits)")[![fey](https://avatars.githubusercontent.com/u/697178?v=4)](https://github.com/fey "fey (9 commits)")[![lakerobin](https://avatars.githubusercontent.com/u/42895793?v=4)](https://github.com/lakerobin "lakerobin (7 commits)")[![bumerang07](https://avatars.githubusercontent.com/u/4818130?v=4)](https://github.com/bumerang07 "bumerang07 (5 commits)")[![joserick](https://avatars.githubusercontent.com/u/15143699?v=4)](https://github.com/joserick "joserick (2 commits)")[![jhermans76](https://avatars.githubusercontent.com/u/5180908?v=4)](https://github.com/jhermans76 "jhermans76 (1 commits)")[![codetestmg](https://avatars.githubusercontent.com/u/13461280?v=4)](https://github.com/codetestmg "codetestmg (1 commits)")[![notarun](https://avatars.githubusercontent.com/u/41166903?v=4)](https://github.com/notarun "notarun (1 commits)")[![pascalbaljet](https://avatars.githubusercontent.com/u/8403149?v=4)](https://github.com/pascalbaljet "pascalbaljet (1 commits)")[![Edpogi](https://avatars.githubusercontent.com/u/14357843?v=4)](https://github.com/Edpogi "Edpogi (1 commits)")[![ataylor32](https://avatars.githubusercontent.com/u/1054222?v=4)](https://github.com/ataylor32 "ataylor32 (1 commits)")[![fchalal](https://avatars.githubusercontent.com/u/40465455?v=4)](https://github.com/fchalal "fchalal (1 commits)")[![ilyes-kechidi](https://avatars.githubusercontent.com/u/482942?v=4)](https://github.com/ilyes-kechidi "ilyes-kechidi (1 commits)")[![edoong](https://avatars.githubusercontent.com/u/53186275?v=4)](https://github.com/edoong "edoong (1 commits)")

---

Tags

phpcomposerlaravelpackagebootstrapFormsform-builder

### Embed Badge

![Health badge](/badges/fey-laravel-bootstrap-4-forms/health.svg)

```
[![Health](https://phpackages.com/badges/fey-laravel-bootstrap-4-forms/health.svg)](https://phpackages.com/packages/fey-laravel-bootstrap-4-forms)
```

###  Alternatives

[netojose/laravel-bootstrap-4-forms

Bootstrap 4 form builder for Laravel 5

182115.3k](/packages/netojose-laravel-bootstrap-4-forms)[metalogico/laravel-formello

A Laravel package for generating Bootstrap 5 and Tailwind CSS 4 forms based on models

1012.2k](/packages/metalogico-laravel-formello)[galahad/bootforms

Form builder with Bootstrap-specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

1161.6k](/packages/galahad-bootforms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
