All Projects → dwightwatson → Bootstrap Form

dwightwatson / Bootstrap Form

Licence: mit
Bootstrap 3 form builder for Laravel

Projects that are alternatives of or similar to Bootstrap Form

Laravel Bootstrap 4 Forms
Bootstrap 4 forms for Laravel 5/6/7/8
Stars: ✭ 181 (-19.56%)
Mutual labels:  laravel, form-builder, bootstrap
Forms
Laravel Enso Form Builder is a customizable, template based form creator, so you can quickly create forms with the minimum amount of effort
Stars: ✭ 114 (-49.33%)
Mutual labels:  laravel, form-builder
Laravel Alert
A Bootstrap alert helper for Laravel
Stars: ✭ 110 (-51.11%)
Mutual labels:  laravel, bootstrap
Lqycms
基于laravel框架的企业级开源cms管理系统,开源php商城源码,B2C微商城系统,企业建站cms。
Stars: ✭ 142 (-36.89%)
Mutual labels:  laravel, bootstrap
Laralack
A Slack clone written in PHP & Laravel framework
Stars: ✭ 82 (-63.56%)
Mutual labels:  laravel, bootstrap
Surveyjs react quickstart
React QuickStart Boilerplate - SurveyJS: Survey Library and Survey Creator
Stars: ✭ 88 (-60.89%)
Mutual labels:  form-builder, bootstrap
Laravel Coreui Vue
Laravel 5.6 with CoreUI (VueJS Full Starter Template) >>> Deprecated, please go to https://coreui.io/laravel/
Stars: ✭ 132 (-41.33%)
Mutual labels:  laravel, bootstrap
Laravel Bootstrap Table List
Bootstrap table list generator for Laravel.
Stars: ✭ 16 (-92.89%)
Mutual labels:  laravel, bootstrap
Formr
Create and Validate PHP Forms in Seconds.
Stars: ✭ 163 (-27.56%)
Mutual labels:  form-builder, bootstrap
Ignition Go
Bootstrap4 /Codeigniter 3 Modular (HMVC) App Building Framework - to build enterprise class web applications... Versions: CodeIgniter 3.1.9 AdminLTE 3.4 Bootstrap 4.5.0
Stars: ✭ 166 (-26.22%)
Mutual labels:  laravel, bootstrap
Wl Bootstrap
Integrating Laravel into WordPress
Stars: ✭ 54 (-76%)
Mutual labels:  laravel, bootstrap
Library Management System
📚 An automated library management system developed in Laravel 4.2 PHP MVC Framework
Stars: ✭ 189 (-16%)
Mutual labels:  laravel, bootstrap
Laravel Settings
Simple Settings package for a laravel application
Stars: ✭ 45 (-80%)
Mutual labels:  laravel, bootstrap
Ecommerce Laravel Bootstrap
Responsive, Multi-Vendor, MultiLanguage Online Store Platform (shopping cart solution)
Stars: ✭ 99 (-56%)
Mutual labels:  laravel, bootstrap
Freelancers Market
Laravel Project to help freelance websites clients and freelancers to find each other.
Stars: ✭ 39 (-82.67%)
Mutual labels:  laravel, bootstrap
Laravel Form Builder
Laravel Form builder for version 5+!
Stars: ✭ 1,601 (+611.56%)
Mutual labels:  laravel, form-builder
Laracms
LaraCMS 是在学习 laravel ( web 开发实战进阶 + 实战构架 API 服务器) 过程中产生的一个业余作品,试图通过简单的方式,快速构建一套基本的企业站同时保留很灵活的扩展能力和优雅的代码方式,当然这些都得益Laravel的优秀设计。同时LaraCMS 也是一个学习Laravel 不错的参考示例。
Stars: ✭ 588 (+161.33%)
Mutual labels:  laravel, bootstrap
Laravel Boilerplate
Laravel Boilerplate / Starter Kit with Gentelella Admin Theme
Stars: ✭ 704 (+212.89%)
Mutual labels:  laravel, bootstrap
Adminlte Laravel
A Laravel 5 package that switchs default Laravel scaffolding/boilerplate to AdminLTE template and Pratt Landing Page with Bootstrap 3.0
Stars: ✭ 1,814 (+706.22%)
Mutual labels:  laravel, bootstrap
Laravel Bootstrap Components
Bootstrap components as Laravel components
Stars: ✭ 190 (-15.56%)
Mutual labels:  laravel, bootstrap

BootstrapForm, forms for Laravel 5

phpunit Total Downloads Latest Stable Version Latest Unstable Version License

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.

Introduction

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

BootForm::text('username');

And you'll get back the following:

<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.

<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.

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).

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):

'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.

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:

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:

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.

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.

// Passing an existing, persisted model will trigger a model
// binded form.
$user = User::whereEmail('[email protected]')->first();

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

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

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.

// 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.

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.

// 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.

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.

// 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.

View the method signature for configuration options.

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

Same goes for radio inputs.

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.

$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.

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

Labels with HTML

To include HTML code inside a label:

// 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.

Form input group (suffix and prefix)

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

// 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'])] ) !!}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].