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
Basic inputs
Text inputs
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
// 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
// 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
// Example
{!! Form::select('city', 'Choose your city', [1 => 'Gotham City', 2 => 'Springfield']) !!}
Checkbox
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$value
string
null
Input value
$default
boolean
null
Default value
// 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
$default
boolean
null
Default value
// Example
{!! Form::radio('orange', 'Orange') !!}
Range
Param
Type
Default
Description
$name
string
null
Input name
$label
string
null
Input label
$default
string
null
Default value
$min
string
0
Minimum value
$max
string
10
Maximum value
$step
string
0.1
Step value
// Example
{!! Form::range('like', 'Like', '2', '0', '20', '1') !!}
Hidden
Param
Type
Default
Description
$name
string
null
Input name
$default
boolean
null
Default value
// Example
{!! Form::hidden('user_id') !!}
Anchor
Param
Type
Default
Description
$value
string
null
Anchor text
$url
string
null
Anchor url
// Example
{!! Form::anchor("Link via parameter", 'foo/bar') !!}
Buttons
Param
Type
Default
Description
$value
string
null
Button value
Submit
// Example
{!! Form::submit("Send form") !!}
Button
// Example
{!! Form::button("Do something") !!}
Reset
// 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
null
// 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
// 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
// Example
{!! Form::anchor("Link via route")->route('home') !!}
Checked
Set the checkbox/radio checked status
Param
Type
Default
Description
$checked
boolean
true
Checked status
// 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) !!}
// Example
{!! Form::text('name', 'Name')->placeholder('Input placeholder') !!}
Select Multiple
// 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
// Example
{!! Form::open()->locale('forms.user') !!}
{!! Form::text('name', 'labels.name') !!}
Help Text
Param
Type
Default
Description
$text
string
null
Help text
// Examples// Conventional way
{!! Form::text('name', 'Name')->help('Help text here') !!}
// Using locale
{!! Form::text('name', 'Name')->help('help.text') !!}
Custom attributes
Param
Type
Default
Description
$attrs
array
[]
Custom input attributes
// Example
{!! Form::text('name', 'Name')->attrs(['data-foo' => 'bar', 'rel'=> 'baz']) !!}
Readonly
Param
Type
Default
Description
$status
boolean
true
Read only status
// Examples// Using readonly field
{!! Form::text('name', 'Name')->readonly() !!}
// You can use FALSE to turn off readonly status
{!! Form::text('name', 'Name')->readonly(false) !!}
Disabled
Param
Type
Default
Description
$status
boolean
true
Disabled status
// Examples// Disabling a field
{!! Form::text('name', 'Name')->disabled() !!}
// You can use FALSE to turn off disabled status
{!! Form::text('name', 'Name')->disabled(false) !!}
Full
Param
Type
Default
Description
$status
boolean
true
Disabled status
// Examples// Field and button at full size
{!! Form::text('name', 'Name')->full() !!}
{!! Form::button('name')->full() !!}
// You can use FALSE to turn off block status
{!! Form::text('name', 'Name')->full(false) !!}