PHPackages                             goldcarrot/laravel-bootstrap-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. goldcarrot/laravel-bootstrap-forms

ActivePackage[Utility &amp; Helpers](/categories/utility)

goldcarrot/laravel-bootstrap-forms
==================================

Provides an easy way to use bootstrap components within your Laravel projects.

v5.2.4(4y ago)0664MITPHP

Since Mar 4Pushed 4y agoCompare

[ Source](https://github.com/GoldCarrot/laravel-bootstrap-forms)[ Packagist](https://packagist.org/packages/goldcarrot/laravel-bootstrap-forms)[ RSS](/packages/goldcarrot-laravel-bootstrap-forms/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (25)Used By (0)

\# Laravel Bootstrap Forms.
===========================

[](#-laravel-bootstrap-forms)

[![Build Status](https://camo.githubusercontent.com/0e68c2e5c98006a76c6cd9d8ab750e906e5630630ee80abcab61c87acbc1f13f/68747470733a2f2f7472617669732d63692e6f72672f6c617261656173742f6c61726176656c2d626f6f7473747261702d666f726d732e737667)](https://travis-ci.org/laraeast/laravel-bootstrap-forms)[![Total Downloads](https://camo.githubusercontent.com/cc19b5149f0d6b6f6bd76c6c6707b941c541577bcb6cbbd399de9b7dbc46c3d3/68747470733a2f2f706f7365722e707567782e6f72672f6c617261656173742f6c61726176656c2d626f6f7473747261702d666f726d732f642f746f74616c2e737667)](https://packagist.org/packages/laraeast/laravel-bootstrap-forms)[![Latest Stable Version](https://camo.githubusercontent.com/f7f148650fd3010a3c6cdd014a01c38039554d8b5244a93092ab5aba905bea92/68747470733a2f2f706f7365722e707567782e6f72672f6c617261656173742f6c61726176656c2d626f6f7473747261702d666f726d732f762f737461626c652e737667)](https://packagist.org/packages/laraeast/laravel-bootstrap-forms)[![License](https://camo.githubusercontent.com/9e0baf0d4399de12d2df95ce5157d5cc22e7ac5c873e902965989b08d75285ab/68747470733a2f2f706f7365722e707567782e6f72672f6c617261656173742f6c61726176656c2d626f6f7473747261702d666f726d732f6c6963656e73652e737667)](https://packagist.org/packages/laraeast/laravel-bootstrap-forms)

- [Installation](#installation)
- [Opening A Form](#opening-a-form)
- [Text, Text Area, Date, Number &amp; Password Fields](#fields)
- [Checkboxes and Radio Buttons](#checkboxes)
- [Drop-Down Lists](#dropdown)
- [Generating A Submit Button](#submit)
- [Supported Methods](#methods)
- [Using Resource With Localed Fields](#resource)
- [Example Register Form](#example)
- [Add Custom Style To The Component](#custom-style)
- [Using Multilingual Form Tabs](#multilingual)
- [Manage Locales](#locales)
- [Using Bootstrap 3](#bootstrap3)
- [Add Custom Component](#custom-component)

\# Installation
===============

[](#-installation)

> Begin by installing this package through Composer. Edit your project's `composer.json` file to require `laraeast/laravel-bootstrap-forms`.

```
composer require laraeast/laravel-bootstrap-forms
```

> You should publish the flags icons in public path to display in multilingual form tabs.

```
php artisan vendor:publish --tag=locales:flags
```

\# Opening A Form
=================

[](#-opening-a-form)

```
{{ BsForm::open(['url' => 'foo/bar']) }}
//
{{ BsForm::close() }}
```

> By default, a `POST` method will be assumed; however, you are free to specify another method:

```
{{ BsForm::open(['url' => 'foo/bar', 'method' => 'post']) }}
```

> Note: Since HTML forms only support `POST` and `GET`, `PUT` and `DELETE` methods will be spoofed by automatically adding a `_method` hidden field to your form.

> You may also open forms with method as well:

```
{{ BsForm::get('foo/bar') }}
{{ BsForm::post('foo/bar') }}
{{ BsForm::put('foo/bar') }}
{{ BsForm::patch('foo/bar') }}
{{ BsForm::delete('foo/bar') }}
{{ BsForm::model($model, 'foo/bar') }}
{{ BsForm::putModel($model, 'foo/bar') }}
{{ BsForm::patchModel($model, 'foo/bar') }}
```

> You may also open forms that point to named routes or controller actions:

```
{{ BsForm::open(['route' => 'route.name']) }}
{{ BsForm::open(['action' => 'Controller@method']) }}
```

> You may pass in route parameters as well:

```
{{ BsForm::open(['route' => ['route.name', $user->id]]) }}
{{ BsForm::open(['action' => ['Controller@method', $user->id]]) }}
```

\# Text, Text Area, Date, Number &amp; Password Fields
======================================================

[](#-text-text-area-date-number--password-fields)

> Generating A Text Input

```
{{ BsForm::text('username') }}
```

Specifying A Default Value
--------------------------

[](#specifying-a-default-value)

```
{{ BsForm::text('email', 'example@gmail.com') }}
{{ BsForm::text('email')->value('example@gmail.com') }}
```

> Note: The date, number and textarea methods have the same signature as the text method.

Generating A Password Input
---------------------------

[](#generating-a-password-input)

```
{{ BsForm::password('password', ['class' => 'awesome']) }}
{{ BsForm::password('password')->attr('class', 'awesome') }}
```

Generating Other Inputs
-----------------------

[](#generating-other-inputs)

```
{{ BsForm::email($name)->value($value)->label($label) }}
{{ BsForm::file($name)->label('Upload File') }}
```

\# Checkboxes and Radio Buttons
===============================

[](#-checkboxes-and-radio-buttons)

Generating A Checkbox Or Radio Input
------------------------------------

[](#generating-a-checkbox-or-radio-input)

```
{{ BsForm::checkbox('name', 'value')->checked(false) }}
{{ BsForm::checkbox('name')->value('value')->checked(false) }}
{{ BsForm::checkbox('name')->value(1)->withDefault()->checked(false) }} {{-- If unchecked will send "0" with request --}}
{{ BsForm::checkbox('name')->value(1)->withoutDefault()->checked(false) }}
{{ BsForm::checkbox('name')->value(1)->default('no')->checked(false) }} {{-- If unchecked will send "no" with request --}}

{{ BsForm::radio('name', 'value')->checked(false)->label('label') }}
{{ BsForm::radio('name')->value('value')->checked(false)->label('label') }}
```

> By default, will send default value "0" with an unchecked checkbox, if you want to disable it globally set the configuration key "laravel-bootstrap-forms.checkboxes.hasDefaultValue": true

\# Drop-Down Lists
==================

[](#-drop-down-lists)

```
{{ BsForm::select('size', ['L' => 'Large', 'S' => 'Small']) }}
{{ BsForm::select('size')->options(['L' => 'Large', 'S' => 'Small']) }}
```

Generating A Drop-Down List With Selected Default
-------------------------------------------------

[](#generating-a-drop-down-list-with-selected-default)

```
{{ BsForm::select('size')->options(['L' => 'Large', 'S' => 'Small'])->value('S') }}
```

Generating a Drop-Down List With an Empty Placeholder
-----------------------------------------------------

[](#generating-a-drop-down-list-with-an-empty-placeholder)

```
{{ BsForm::select('size')->options(['L' => 'Large', 'S' => 'Small'])->placeholder('Select Size') }}
```

Generating A Grouped List
-------------------------

[](#generating-a-grouped-list)

```
{{ BsForm::select('animal',[
         'Cats' => ['leopard' => 'Leopard'],
         'Dogs' => ['spaniel' => 'Spaniel'],
   ]) }}
```

\# Generating A Submit Button
=============================

[](#-generating-a-submit-button)

```
{{ BsForm::submit('Click Me!') }}
```

Generateing A Submit Button With Bootstrap Button Style
-------------------------------------------------------

[](#generateing-a-submit-button-with-bootstrap-button-style)

```
{{ BsForm::submit('Click Me!')->success() }}
{{ BsForm::submit('Click Me!')->primary() }}
{{ BsForm::submit('Click Me!')->info() }}
{{ BsForm::submit('Click Me!')->warning() }}
{{ BsForm::submit('Click Me!')->danger() }}
```

\# Supported Methods
====================

[](#-supported-methods)

> `->label($label) ` : To Generate label to the specified field.

```
{{ BsForm::text('username')->label('Username') }}
```

> `->name($name) ` : To Generate label to the specified field.

```
{{ BsForm::text('username')->label('Username') }}
```

> `->placeholder($placeholder) ` : To Set placeholder attribute to the specified field.

```
{{ BsForm::text('username')->placeholder('Please Enter Your Name') }}
```

> `->min($min)` : To Set min attribute to the specified number field.

```
{{ BsForm::number('age')->min(10) }}
```

> `->max($max)` : To Set max attribute to the specified number field.

```
{{ BsForm::number('age')->min(10)->max(30) }}
```

> `->step($step)` : To Set step attribute to the specified number field.

```
{{ BsForm::number('age')->min(10)->max(30)->step(1) }}
```

> `->multiple($bool = true)` : To Set multiple attribute to the specified select and file fields.

```
{{ BsForm::file('photos[]')->multiple() }}
```

> `->note($note)` : To Set `help-block` to the specified field.

```
{{ BsForm::text('username')->note('Example: Ahmed Fathy') }}
```

> `->name($name)` : To Set the name of to the specified field.

```
{{ BsForm::text()->name('username')->note('Example: Ahmed Fathy') }}
```

> `->value($value)` : To Set the value of to the specified field as default will set `old('name')`.

```
{{ BsForm::text()->name('username')->value('Ahmed Fathy') }}
```

> `->inlineValidation($bool = true)` : To display validation errors in the specified field.

```
{{ BsForm::text('username')->style('vertical')->inlineValidation(false) }}
```

> `->style($style = 'default')` : To Set style to the specified field. supported `['default', 'vertical']`.

```
{{ BsForm::text('username')->style('vertical') }}
{{ BsForm::text('email')->style('default') }}
```

> `->close()` : To close the form tag.

```
{{ BsForm::close() }}
```

\# Using Resource With Localed Fields
=====================================

[](#-using-resource-with-localed-fields)

> You may add localed labels, notes and placeholders using resource option as well:

```
@php(BsForm::resource('users'))
```

> You must add `users.php` file to the `resources/lang/en/` path and set the default attributes and notes, placeholders as well:

```
