2017 © Pedro Peláez
 

library bootstrap-form

Laravel 5 form wrappers for Bootstrap 3.

image

watson/bootstrap-form

Laravel 5 form wrappers for Bootstrap 3.

  • Tuesday, June 19, 2018
  • by dwightwatson
  • Repository
  • 14 Watchers
  • 205 Stars
  • 129,208 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 104 Forks
  • 17 Open issues
  • 57 Versions
  • 8 % Grown

The README.md

BootstrapForm, forms for Laravel 5

phpunit Total Downloads Latest Stable Version Latest Unstable Version License, (*1)

This is a package for simply creating Bootstrap 3 styled form groups in Laravel 5. It extends the normal form builder to provide you with horizontal form groups completed with labels, error messages and appropriate class usage., (*2)

Introduction

Simply use the BootstrapForm facade in the place of the Form facade when you want to generate a Bootstrap 3 form group., (*3)

BootForm::text('username');

And you'll get back the following:, (*4)

<div class="form-group">
    <label for="username" class="control-label col-md-2">Username</label>
    <div class="col-md-10">
        <input type="text" name="username" class="form-control" />
    </div>
</div>

Of course, if there are errors for that field it will even populate them., (*5)

<div class="form-group has-error">
    <label for="username" class="control-label col-md-2">Username</label>
    <div class="col-md-10">
        <input type="text" name="username" class="form-control" />
        <span class="help-block">The username field is required.</span>
    </div>
</div>

Installation

First, require the package using Composer., (*6)

composer require watson/bootstrap-form

Now, add these service providers to your config/app.php file (don't add the HtmlServiceProvider if you already have it)., (*7)

Collective\Html\HtmlServiceProvider::class,
Watson\BootstrapForm\BootstrapFormServiceProvider::class,

And finally add these to the aliases array (note: Form and Html must be listed before BootstrapForm):, (*8)

'Form'     => Collective\Html\FormFacade::class,
'HTML'     => Collective\Html\HtmlFacade::class,
'BootForm' => Watson\BootstrapForm\Facades\BootstrapForm::class,

Feel free to use a different alias for BootstrapForm if you'd prefer something shorter., (*9)

Configuration

There are a number of configuration options available for BootstrapForm. Run the following Artisan command to publish the configuration option to your config directory:, (*10)

php artisan vendor:publish

Horizontal form sizes

When using a horizontal form you can specify here the default sizes of the left and right columns. Note you can specify as many classes as you like for each column for improved mobile responsiveness, for example:, (*11)

col-md-3 col-sm-6 col-xs-12

Display errors

By default this package will only display the first validation error for each field. If you'd instead like to list out all the validation errors for a field, simply set this configuration option to true., (*12)

Usage

Opening a form

BootstrapForm has improved the process of opening forms, both in terms of providing Bootstrap classes as well as managing models for model-based forms., (*13)

// Passing an existing, persisted model will trigger a model
// binded form.
$user = User::whereEmail('example@example.com')->first();

// Named routes
BootForm::open(['model' => $user, 'store' => 'users.store', 'update' => 'users.update']);

// Controller actions
BootForm::open(['model' => $user, 'store' => 'UsersController@store', 'update' => 'UsersController@update']);

If a model is passed to the open method, it will be configured to use the update route with the PUT method. Otherwise it will point to the store method as a POST request. This way you can use the same opening tag for a form that handles creating and saving., (*14)

// Passing a model that hasn't been saved or a null value as the
// model value will trigger a `store` form.
$user = new User;

BootForm::open()

Routing with parameters

If the route takes parametersyou can pass them by replacing the route or action name string bwith an array. The first entry is the string for route name, followed by the parameters as you'd pass them to the route function., (*15)

BootForm::open(['update' => ['posts.comments.create', $post]])

Form variations

There are a few helpers for opening the different kinds of Bootstrap forms. By default, open() will use the the form style that you have set in the configuration file. These helpers take the same input as the open() method., (*16)

// Open a vertical Bootstrap form.
BootForm::vertical();

// Open an inline Bootstrap form.
BootForm::inline();

// Open a horizontal Bootstrap form.
BootForm::horizontal();

If you want to change the columns for a form for a deviation from the settings in your configuration file, you can also set them through the $options array., (*17)

BootForm::open(['left_column_class' => 'col-md-2', 'left_column_offset_class' => 'col-md-offset-2', 'right_column_class' => 'col-md-10']);

Text inputs

Here are the various methods for text inputs. Note that the method signatures are relatively close to those provided by the Laravel form builder but take a parameter for the form label., (*18)

// The label will be inferred as 'Username'.
BootForm::text('username');

// The field name by default is 'email'.
BootForm::email();

BootForm::textarea('profile');

// The field name by default is 'password'.
BootForm::password();

Checkbox and radio button inputs

Checkboxes and radio buttons are a little bit different and generate different markup., (*19)

View the method signature for configuration options., (*20)

// A checked checkbox.
BootForm::checkbox('interests[]', 'Laravel', 'laravel', true);

Same goes for radio inputs., (*21)

BootForm::radio('gender', 'Male', 'male');

Multiple checkboxes and radio buttons

By simply passing an array of value/label pairs you can generate a group of checkboxes or radio buttons easily., (*22)

$label = 'this is just a label';

$interests = [
    'laravel' => 'Laravel',
    'rails'   => 'Rails',
    'ie6'     => 'Internet Explorer 6'
];

// Checkbox inputs with Laravel and Rails selected.
BootForm::checkboxes('interests[]', $label, $interests, ['laravel', 'rails']);

$genders = [
    'male'   => 'Male',
    'female' => 'Female'
];

// Gender inputs inline, 'Gender' label inferred.
BootForm::radios('gender', null, $genders, null, true);

// Gender inputs with female selected.
BootForm::radios('gender', 'Gender', $genders, 'female');

Submit button

// Pretty simple.
BootForm::submit('Login');

Closing the form

// Pretty simple.
BootForm::close();

Labels

Hide Labels

You may hide an element's label by setting the the value to false., (*23)

// An input with no label.
BootForm::text('username', false);

Labels with HTML

To include HTML code inside a label:, (*24)

// A label with HTML code using array notation
BootForm::text('username', ['html' => 'Username <span class="required">*</span>']);

// A label with HTML code using HtmlString object
BootForm::text('username', new Illuminate\Support\HtmlString('Username <span class="required">*</span>'));

Help Text

You may pass a help_text option to any field to have Bootstrap Help Text appended to the rendered form group., (*25)

Form input group (suffix and prefix)

Add prefix and/or suffix to any input - you can add text, icon and buttons., (*26)

// Suffix button with 'Call' as label and success class to button
{!! BootForm::text('tel', 'Phone', null, ['suffix' => BootForm::addonButton('Call', ['class' => 'btn-success'])] ) !!}

// Prefix button with 'Call' as label and success class to button
{!! BootForm::text('tel', 'Phone', null, ['prefix' => BootForm::addonButton('Call', ['class' => 'btn-success'])] ) !!}

// Prefix icon (I put second parameter after <i class="fa fa-SECOND_PARAMETER"></i>) with 'dollar' as icon
{!! BootForm::text('tel', 'Phone', null, ['prefix' => BootForm::addonIcon('dollar')] ) !!}

// Prefix and suffix as text
{!! BootForm::text('tel', 'Phone', null, ['prefix' => BootForm::addonText('1-'), 'suffix' => BootForm::addonIcon('phone')] ) !!}

// Prefix and suffix with button
{!! BootForm::text('tel', 'Phone', null, ['suffix' => BootForm::addonButton('Boom!', ['class' => 'btn-danger']), 'prefix' => BootForm::addonButton('Call', ['class' => 'btn-success'])] ) !!}

The Versions

19/06 2018

dev-master

9999999-dev

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

19/06 2018

1.1.18

1.1.18.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

12/04 2018

1.1.17

1.1.17.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

12/04 2018

1.1.16

1.1.16.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

03/02 2018

1.1.15

1.1.15.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

16/12 2017

1.1.14

1.1.14.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

06/11 2017

1.1.13

1.1.13.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

01/11 2017

1.1.12

1.1.12.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

07/09 2017

1.1.11

1.1.11.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

07/09 2017

dev-feature/error-bag

dev-feature/error-bag

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

14/08 2017

1.1.10

1.1.10.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

25/07 2017

1.1.9

1.1.9.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

28/06 2017

1.1.8

1.1.8.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

07/04 2017

1.1.7

1.1.7.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

29/03 2017

1.1.6

1.1.6.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

26/03 2017

1.1.5

1.1.5.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

17/03 2017

1.1.4

1.1.4.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

06/03 2017

1.1.3

1.1.3.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

11/02 2017

1.1.2

1.1.2.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

10/01 2017

1.1.1

1.1.1.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

10/01 2017

1.1.0

1.1.0.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

02/01 2017

1.0.20

1.0.20.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

08/12 2016

1.0.19

1.0.19.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

21/11 2016

1.0.18

1.0.18.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

24/10 2016

1.0.17

1.0.17.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

30/09 2016

1.0.16

1.0.16.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

28/07 2016

1.0.15

1.0.15.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

28/07 2016

1.0.14

1.0.14.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

11/05 2016

1.0.13

1.0.13.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

10/05 2016

1.0.12

1.0.12.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

06/03 2016

1.0.11

1.0.11.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

14/01 2016

1.0.10

1.0.10.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

27/12 2015

1.0.9

1.0.9.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

29/09 2015

1.0.8

1.0.8.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

23/09 2015

1.0.7

1.0.7.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

21/09 2015

1.0.6

1.0.6.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

06/09 2015

1.0.5

1.0.5.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

02/09 2015

1.0.4

1.0.4.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

30/07 2015

1.0.3

1.0.3.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

27/06 2015

1.0.2

1.0.2.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

17/06 2015

1.0.1

1.0.1.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

02/06 2015

1.0.0

1.0.0.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

20/05 2015

0.8.6

0.8.6.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

17/05 2015

0.9.6

0.9.6.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

10/05 2015

0.9.5

0.9.5.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

30/03 2015

0.9.4

0.9.4.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

20/03 2015

0.9.2

0.9.2.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

20/03 2015

0.9.3

0.9.3.0

Laravel 5 form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

21/10 2014

0.9.1

0.9.1.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

28/09 2014

0.9.0

0.9.0.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

20/09 2014

0.8.x-dev

0.8.9999999.9999999-dev

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

19/09 2014

0.8.5

0.8.5.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

19/09 2014

0.8.4

0.8.4.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

02/07 2014

0.8.3

0.8.3.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

13/06 2014

0.8.2

0.8.2.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

12/06 2014

0.8.1

0.8.1.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap

04/06 2014

0.8.0

0.8.0.0

Laravel 4.2+ form wrappers for Bootstrap 3.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dwight Watson

laravel form bootstrap