3.3 Inputs Methods - joserick/laravel-bootstrap-4-forms GitHub Wiki

Inputs methods

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)!!}

Inline

Set the checkbox/radio checked status

// 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)!!}

Select Multiple

// Example
{!!Form::select('city', 'Choose your city', [1 => 'Gotham City', 2 => 'Springfield'])->multiple()!!}

Placeholder

Param Type Default Description
$placeholder string null Placeholder text
// Example
{!!Form::text('name', 'Name')->placeholder('Input placeholder')!!}

// Also works with select
{!!Form::select('city', 'Choose your city', $cities)->placeholder('Select you city')!!}

Custom attributes

Param Type Default Description
$attrs array [] Custom input attributes
// Example
{!!Form::text('name', 'Name')->attrs(['data-foo' => 'bar', 'rel'=> 'baz'])!!}

Required

Param Type Default Description
$status boolean true Required status
// Examples

// Disabling a field
{!!Form::text('name', 'Name')->required()!!}

// Disabling a fieldset
{!!Form::fieldsetOpen('User data')->required()!!}

// You can use FALSE to turn off required status
{!!Form::text('name', 'Name')->required(false)!!}

Help Text

Param Type Default Description
$text string null Help text
// Example
{!!Form::text('name', 'Name')->help('Help text here')!!}

Custom attributes in wrapper div (<div class="form-group">...</div>)

Param Type Default Description
$attrs array [] Custom input attributes
// Example
{!!Form::text('name', 'Name')->wrapperAttrs(['data-foo' => 'bar', 'id'=> 'name-wrapper'])!!}

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()!!}

// Disabling a fieldset
{!!Form::fieldsetOpen('User data')->disabled()!!}

// You can use FALSE to turn off disabled status
{!!Form::text('name', 'Name')->disabled(false)!!}

Block

Param Type Default Description
$status boolean true Disabled status
// Examples

// Disabling a field
{!!Form::text('name', 'Name')->block()!!}

// You can use FALSE to turn off block status
{!!Form::text('name', 'Name')->block(false)!!}

Id

Param Type Default Description
$id string null Id field
// Example
{!!Form::text('name', 'Name')->id('user-name')!!}

Min

Param Type Default Description
$value number null Minimum value

Set min attribute for input

// Example
{!!Form::text('age', 'Your age')->type('number')->min(18)!!}

Max

Param Type Default Description
$value number null Minimum value

Set max attribute for input

// Example
{!!Form::text('age', 'Your age')->type('number')->max(18)!!}

Name

Param Type Default Description
$name string null Input name
// Examples
{!!Form::text('text')->name('name')!!}

Label

Param Type Default Description
$label string null Input label
$attrs string [] Attributes label
// Examples
{!!Form::text('age')->label('Your age')!!}

// Only attributes for label
{!!Form::text('age')->labelAttrs(['id' => 'input-label'])!!}

Default Value

Param Type Default Description
$value mixed null Input value
// Example
{!!Form::text('name', 'Your name')->value('Maria')!!}

Render

Param Type Default Description
$render string null Render name
// Examples

// Number field
{!!Form::render('text')->name('age')->label('Your age')!!}

Disable is-valid CSS Class

Param Type Default Description
$disableIsValid boolean true Disable is-valid CSS class
// Examples

// Disable Bootstrap's is-valid CSS class
{!!Form::text('name', 'Name')->disableIsValid()!!}

Disable validation messages

Disable success/error status and validation error message

Param Type Default Description
$disabled boolean false Disabled status
// 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)!!}

AutoFill

Param Type Default Description
$value string 'on' autocomplte value

see: https://html.spec.whatwg.org/multipage/forms.html#autofill

If no autocomplete value is specified on the form, html spec requires a default value of 'on'. So, you must explicitly turn it off.

Autocomplete values will be automatically generated for fields with single word names matching valid values (e.g. name, email, tel, organization). The complete list is in the spec mentioned above.

// Examples

// Switch off autocomplete for the form
{!!Form::open()->autocomplete('off')!!}

// Explicitly set a autocomplete value
{!!Form::text('mobile', 'Mobile Number')->autocomplete('tel')!!}

// Disable autocomplete for fields with valid names
{!!Form::text('name', 'Name')->autocomplete('off')!!}

Chaining properties

You can use chaining feature to use a lot of settings for each component

// Examples

{!!Form::open()->locale('forms.user')->put()->multipart()->route('user.add')->data($user)!!}

{!!Form::text('name', 'Name')->placeholder('Type your name')->lg()!!}

{!!Form::anchor("Link as a button")->sm()->info()->outline()!!}

{!!Form::submit('Awesome button')->id('my-btn')->disabled()->danger()->lg()!!}

{!!Form::close()!!}
⚠️ **GitHub.com Fallback** ⚠️