2017 © Pedro Peláez
 

library bootforms

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

image

galahad/bootforms

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

  • Monday, February 19, 2018
  • by inxilpro
  • Repository
  • 1 Watchers
  • 6 Stars
  • 1,807 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 106 Forks
  • 0 Open issues
  • 39 Versions
  • 63 % Grown

The README.md

Build Status Coverage Status, (*1)

BootForms

BootForms is a Laravel package to rapidly generate markup for standard Bootstrap 3 forms. Probably not perfect for your super custom branded ready-for-release apps, but a huge time saver when you are still in the prototyping stage!, (*2)

Check out Aire

This package has been replaced by Aire which is a modern form builder with similar features but an improved API, more tests, more documentation, and support for non-Bootstrap themes. It uses Tailwind by default, but has full support for Bootstrap via a plugin., (*3)

BootForms is no longer actively maintained. I'll try to merge any bugfixes for the forseeable future, but I strongly urge you to check out Aire., (*4)

Fork

This package forks abandoned Adam Wathan's repository to provide support for newer Laravel versions as well as following changes over the original package:, (*5)

  • support for package autodiscovery
  • improved support for IDE autocompletion (using laravel-ide-helper)
  • improved support for model binding
  • changed into Laravel-only package to simplify experience even more
  • dropped support for Laravel versions older than 5.5

Table of Contents

Installing with Composer

This package supports Laravel autodiscovery so all you have to do is running this command in your terminal in the root of your project:, (*6)

composer require galahad/bootforms

Using BootForms

Basic Usage

BootForms lets you create a label and form control and wrap it all in a form group in one call., (*7)

//  <form method="POST">
//    <div class="form-group">
//      <label for="field_name">Field Label</label>
//      <input type="text" class="form-control" id="field_name" name="field_name">
//    </div>
//  </form>
{!! BootForm::open() !!}
{!! BootForm::text('Field Label', 'field_name') !!}
{!! BootForm::close() !!}

Note: Don't forget to open() forms before trying to create fields! BootForms needs to know if you opened a vertical or horizontal form before it can render a field, so you'll get an error if you forget., (*8)

Customizing Elements

If you need to customize your form elements in any way (such as adding a default value or placeholder to a text element), simply chain the calls you need to make and they will fall through to the underlying form element., (*9)

Attributes can be added either via the attribute method, or by simply using the attribute name as the method name., (*10)

// 

// // //
BootForm::text('First Name', 'first_name')->placeholder('John Doe'); //
// // //
BootForm::select('Color', 'color')->options(['red' => 'Red', 'green' => 'Green'])->select('green'); // < form method="GET" action="/users"> BootForm::open()->get()->action('/users'); //
// // //
BootForm::text('First Name', 'first_name')->defaultValue('John Doe');

For more information about what's possible, check out the documentation for the basic Forms package., (*11)

Reduced Boilerplate

Typical Bootstrap form boilerplate might look something like this:, (*12)

<form>
  <div class="form-group">
    <label for="first_name">First Name</label>
    <input type="text" class="form-control" name="first_name" id="first_name">
  </div>
  <div class="form-group">
    <label for="last_name">Last Name</label>
    <input type="text" class="form-control" name="last_name" id="last_name">
  </div>
  <div class="form-group">
    <label for="date_of_birth">Date of Birth</label>
    <input type="date" class="form-control" name="date_of_birth" id="date_of_birth">
  </div>
  <div class="form-group">
    <label for="email">Email address</label>
    <input type="email" class="form-control" name="email" id="email">
  </div>
  <div class="form-group">
    <label for="password">Password</label>
    <input type="password" class="form-control" name="password" id="password">
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

BootForms makes a few decisions for you and allows you to pare it down a bit more:, (*13)

{!! BootForm::open() !!}
  {!! BootForm::text('First Name', 'first_name') !!}
  {!! BootForm::text('Last Name', 'last_name') !!}
  {!! BootForm::date('Date of Birth', 'date_of_birth') !!}
  {!! BootForm::email('Email', 'email') !!}
  {!! BootForm::password('Password', 'password') !!}
  {!! BootForm::submit('Submit') !!}
{!! BootForm::close() !!}

Automatic Validation State

Another nice thing about BootForms is that it will automatically add error states and error messages to your controls if it sees an error for that control in the error store., (*14)

Essentially, this takes code that would normally look like this:, (*15)

<div class="form-group {!! $errors->has('first_name') ? 'has-error' : '' !!}">
  <label for="first_name">First Name</label>
  <input type="text" class="form-control" id="first_name">
  {!! $errors->first('first_name', '<p class="help-block">:message</p>') !!}
</div>

And reduces it to this:, (*16)

{!! BootForm::text('First Name', 'first_name') !!}

...with the has-error class being added automatically if there is an error in the session., (*17)

Horizontal Forms

To use a horizontal form instead of the standard basic form, simply swap the BootForm::open() call with a call to openHorizontal($columnSizes) instead:, (*18)


// Width in columns of the left and right side // for each breakpoint you'd like to specify. $columnSizes = [ 'sm' => [4, 8], 'lg' => [2, 10] ]; {!! BootForm::openHorizontal($columnSizes) !!} {!! BootForm::text('First Name', 'first_name') !!} {!! BootForm::text('Last Name', 'last_name') !!} {!! BootForm::text('Date of Birth', 'date_of_birth') !!} {!! BootForm::email('Email', 'email') !!} {!! BootForm::password('Password', 'password') !!} {!! BootForm::submit('Submit') !!} {!! BootForm::close() !!}

Additional Tips

Hiding Labels

You can hide labels by chaining the hideLabel() helper off of any element definition., (*19)

BootForm::text('First Name', 'first_name')->hideLabel(), (*20)

The label will still be generated in the markup, but hidden using Bootstrap's .sr-only class, so you don't reduce the accessibility of your form., (*21)

Help Blocks

You can add a help block underneath a form element using the helpBlock() helper., (*22)

BootForm::text('Password', 'password')->helpBlock('A strong password should be long and hard to guess.'), (*23)

Note: This help block will automatically be overridden by errors if there are validation errors., (*24)

Model Binding

BootForms makes it easy to bind an object to a form to provide default values. Read more about it here., (*25)

BootForm::open()->action( route('users.update', $user) )->put()
BootForm::bind($user)
BootForm::close()

The Versions

19/02 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

19/02 2018

1.1.0

1.1.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.10

1.0.10.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.9

1.0.9.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.8

1.0.8.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.7

1.0.7.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.6

1.0.6.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.5

1.0.5.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.4

1.0.4.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

27/09 2017

v1.0.3

1.0.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

21/09 2017

v1.0.2

1.0.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

21/09 2017

v1.0.1

1.0.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

21/09 2017

v1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

laravel bootstrap forms bootform bootforms

18/07 2017

v0.9.0

0.9.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

26/04 2017

v0.8.5

0.8.5.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

31/01 2017

v0.8.4

0.8.4.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

19/01 2017

v0.8.3

0.8.3.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

20/09 2016

v0.8.2

0.8.2.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

09/06 2016

v0.8.1

0.8.1.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

28/02 2016

dev-aw-updates-for-form-0.9

dev-aw-updates-for-form-0.9

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

11/02 2016

v0.8.0

0.8.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

08/12 2015

v0.7.1

0.7.1.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

02/12 2015

dev-aw-group-wrapper-targets

dev-aw-group-wrapper-targets

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

10/09 2015

v0.7.0

0.7.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

12/06 2015

v0.6.3

0.6.3.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

11/06 2015

v0.6.2

0.6.2.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

09/06 2015

v0.6.1

0.6.1.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

01/05 2015

dev-input-groups

dev-input-groups

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

30/04 2015

v0.6.0

0.6.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

15/04 2015

v0.5.0

0.5.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

15/04 2015

dev-aw-custom-breakpoint-columns

dev-aw-custom-breakpoint-columns

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

07/02 2015

v0.4.2

0.4.2.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

29/09 2014

v0.4.1

0.4.1.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

17/09 2014

v0.4.0

0.4.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

12/08 2014

v0.3.1

0.3.1.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

11/08 2014

dev-dev

dev-dev

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

13/07 2014

v0.3.0

0.3.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

24/03 2014

v0.2

0.2.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

09/10 2013

v0.1

0.1.0.0

Just a Formbuilder with some Bootstrap specific conveniences. Remembers old input, retrieves error messages and handles all your boilerplate Bootstrap markup automatically.

  Sources   Download

The Requires

 

The Development Requires

by Adam Wathan