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
Add the service provider to your config/app.php file
// 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
php
// Making all inputs inline
{!!Form::open()->formInline()!!}
// You can use FALSE to turn off disable form inline
{!!Form::open()->formInline(false)!!}
Fieldset
Param
Type
Default
Description
$legend
string
null
Fieldset Legend
php
// Example
{!!Form::fieldsetOpen('Legend title')!!}
// ... fieldset content
{!!Form::fieldsetClose()!!}
Basic inputs
Text inputs
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
php
// Example
{!!Form::text('name', 'User name')!!}
Textarea
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
php
// Example
{!!Form::textarea('description', 'Description')!!}
Select
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$options
array
[]
Select options
$default
string
null
Default value
php
// Example
{!!Form::select('city', 'Choose your city', [1 => 'Gotham City', 2 => 'Springfield'])!!}
Options
Param
Type
Default
Description
$options
iterable
[]
Options list
$valueKey
string
null
key for value
$idKey
string
null
key for id
…
Checkbox
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$value
string
null
Input value
$checked
boolean
null
Default value
php
// Example
{!!Form::checkbox('orange', 'Orange')!!}
Radio
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$value
string
null
Input value
$checked
boolean
null
Default value
php
// Example
{!!Form::radio('orange', 'Orange')!!}
File
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
php
// Example
{!!Form::file('doc', 'Document')!!}
Date inputs
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
php
// Example
{!!Form::date('birthday', 'Birthday')!!}
Tel inputs
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
php
// Example
{!!Form::tel('number', 'Phone number')!!}
Time inputs
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
php
// Example
{!!Form::time('hour', 'Meeting hour')!!}
URL inputs
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
php
// Example
{!!Form::urlInput('website', 'You website')!!}
Range inputs
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
php
// Example
{!!Form::range('name', 'User name')!!}
Hidden
Param
Type
Default
Description
$name
string
null
Input name
$default
boolean
null
Default value
php
// Example
{!!Form::hidden('user_id')!!}
Anchor
Param
Type
Default
Description
$value
string
null
Anchor text
$url
string
null
Anchor url
php
// Example
{!!Form::anchor("Link via parameter", 'foo/bar')!!}
Buttons
Param
Type
Default
Description
$value
string
null
Button value
$color
string
null
Button color
$size
string
null
button size
Submit
php
// Example
{!!Form::submit("Send form")!!}
Button
php
// Example
{!!Form::button("Do something", "warning", "lg")!!}
Reset
php
// Example
{!!Form::reset("Clear form")!!}
Chainable methods
This package uses chaining feature, allowing easly pass more parameters.
Filling a form
Param
Type
Default
Description
$data
object/array
array
Data fo fill form inputs
php
// 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
Use in anchors and forms openings
Param
Type
Default
Description
$url
string
null
Url
php
// Example
{!!Form::anchor("Link via url")->url('foo/bar')!!}
Route
Use in anchors and forms openings
Param
Type
Default
Description
$route
string
null
Route name
php
// Example
{!!Form::anchor("Link via route")->route('home')!!}
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
Param
Type
Default
Description
$value
string
null
Error bag name
…
Errors
Show all errors inside a panel
Param
Type
Default
Description
$title
string
null
Panel title
php
// Example
{!!Form::errors("The form has errors")!!}
Disable validation messages
Disable success/error status and validation error message
Param
Type
Default
Description
$disabled
boolean
false
Disabled status
php
// 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
Set the checkbox/radio checked status
Param
Type
Default
Description
$checked
boolean
true
Checked status
php
// 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
Set the checkbox/radio checked status
php
// 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
Param
Type
Default
Description
$placeholder
string
null
Placeholder text
php
// Example
{!!Form::text('name', 'Name')->placeholder('Input placeholder')!!}
Select Multiple
php
// Example
{!!Form::select('city', 'Choose your city', [1 => 'Gotham City', 2 => 'Springfield'])->multiple()!!}
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
php
// Example
{!!Form::open()->locale('forms.user')!!}
Help Text
Param
Type
Default
Description
$text
string
null
Help text
php
// Example
{!!Form::text('name', 'Name')->help('Help text here')!!}
Custom attributes
Param
Type
Default
Description
$attrs
array
[]
Custom input attributes
php
// Example
{!!Form::text('name', 'Name')->attrs(['data-foo' => 'bar', 'rel'=> 'baz'])!!}
Custom attributes in wrapper div (\
)
Param
Type
Default
Description
$attrs
array
[]
Custom input attributes
php
// Example
{!!Form::text('name', 'Name')->wrapperAttrs(['data-foo' => 'bar', 'id'=> 'name-wrapper'])!!}
Readonly
Param
Type
Default
Description
$status
boolean
true
Read only status
php
// Examples// Using readonly field
{!!Form::text('name', 'Name')->readonly()!!}
// You can use FALSE to turn off readonly status
{!!Form::text('name', 'Name')->readonly(false)!!}