eduardosaveiga/laravel-uikit-3-forms is a Laravel package for uikit 3 form builder for laravel 5.
It currently has 5 GitHub stars and 44 downloads on Packagist.
Install it with composer require eduardosaveiga/laravel-uikit-3-forms.
Discover more Laravel packages by eduardosaveiga
or browse all Laravel packages to compare alternatives.
Last updated
This is a package for creating UIKit 3 styled form elements in Laravel 5.
<div class="uk-margin">
<label class="uk-form-label" for="username">Username</label>
<input type="text" class="uk-input @if ($errors->has('username')) uk-form-danger @endif " id="username" value="{{ old('username', $username) }}">
@if ($errors->has('username'))
<span class="uk-label uk-label-danger">
<small>{{ $errors->first('username') }}
</div>
@endif
</div>
Form::text('username', 'Username')
composer require eduardosaveiga/laravel-uikit-3-forms
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.
'providers' => [
//...
EduardoVeiga\Uikit3Forms\Uikit3FormsServiceProvider::class,
],
'aliases' => [
//...
'Form' => EduardoVeiga\Uikit3Forms\Uikit3FormsFacade::class,
],
// Opening a form using POST method
{!! Form::open() !!}
// ... Form components here
{!! Form::close() !!}
Opening the form will add _token field automatically for you
| 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') !!}
| Param | Type | Default | Description | | -------- | ------ | ------- | ------------- | | $name | string | null | Input name | | $label | string | null | Input label | | $default | string | null | Default value |
// Example
{!! Form::textarea('description', 'Description') !!}
| 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']) !!}
| 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') !!}
| 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') !!}
| 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') !!}
| Param | Type | Default | Description | | -------- | ------- | ------- | ------------- | | $name | string | null | Input name | | $default | boolean | null | Default value |
// Example
{!! Form::hidden('user_id') !!}
| Param | Type | Default | Description | | ------ | ------ | ------- | ----------- | | $value | string | null | Anchor text | | $url | string | null | Anchor url |
// Example
{!! Form::anchor("Link via parameter", 'foo/bar') !!}
| Param | Type | Default | Description | | ------ | ------ | ------- | ------------ | | $value | string | null | Button value |
// Example
{!! Form::submit("Send form") !!}
// Example
{!! Form::button("Do something") !!}
// Example
{!! Form::reset("Clear form") !!}
This package uses chaining feature, allowing easly pass more parameters.
| Param | Type | Default | Description | | ----- | ------ | ------- | ----------- | | $data | object | array | null | Data fo fill form inputs |
// 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) !!}
Use in anchors and forms openings
| Param | Type | Default | Description | | ----- | ------ | ------- | ----------- | | $url | string | null | Url |
// Example
{!! Form::anchor("Link via url")->url('foo/bar') !!}
Use in anchors and forms openings
| Param | Type | Default | Description | | ------ | ------ | ------- | ----------- | | $route | string | null | Route name |
// Example
{!! Form::anchor("Link via route")->route('home') !!}
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) !!}
Set the checkbox/radio checked status
// Examples
{!! Form::radio('orange', 'Orange')->inline() !!}
{!! Form::checkbox('orange', 'Orange')->inline() !!}
| Param | Type | Default | Description | | ------------ | ------ | ------- | ---------------- | | $placeholder | string | null | Placeholder text |
// Example
{!! Form::text('name', 'Name')->placeholder('Input placeholder') !!}
// Example
{!! Form::select('city', 'Choose your city', [1 => 'Gotham City', 2 => 'Springfield'])->multiple() !!}
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') !!}
| 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') !!}
| Param | Type | Default | Description | | ------ | ----- | ------- | ----------------------- | | $attrs | array | [] | Custom input attributes |
// Example
{!! Form::text('name', 'Name')->attrs(['data-foo' => 'bar', 'rel'=> 'baz']) !!}
| 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) !!}
| 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) !!}
| 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) !!}
| Param | Type | Default | Description | | ------- | ------- | ------- | --------------- | | $icon | string | null | UIKit icon name | | $flip | boolean | false | Side of icon | | $clickable | boolean | false | Icon inside an anchor | | | | | (only works with inputs) | | $attrs | array | empty | Attributes |
// Examples
{!! Form::text('email', 'Email')->icon('mail') !!}
{!! Form::button('send')->icon('check', true) !!}
| Param | Type | Default | Description | | ----- | ------ | ------- | ----------- | | $id | string | null | Id field |
// Example
{!! Form::text('name', 'Name')->id('user-name') !!}
All ids will prepend by this prefix like: prefix-myid
| Param | Type | Default | Description | | ------- | ------ | ------- | ----------- | | $prefix | string | null | Id prefix |
// Example
{!!Form::open()->prefix('register')!!}
| Param | Type | Default | Description | | ---------- | ------- | ------- | -------------- | | $multipart | boolean | true | Multipart flag |
// Examples
{!! Form::open()->multipart() !!}
// You can use FALSE to turn off multipart
{!! Form::open()->multipart(false) !!}
| Param | Type | Default | Description | | ------- | ------ | ------- | ----------- | | $method | string | null | HTTP method |
// Examples
{!! Form::open()->method('get') !!}
{!! Form::open()->method('post') !!}
{!! Form::open()->method('put') !!}
{!! Form::open()->method('patch') !!}
{!! Form::open()->method('delete') !!}
| Param | Type | Default | Description | | ------ | ------ | ------- | ----------- | | $color | string | null | Color name |
// Examples
{!! Form::button("Do something")->color('primary') !!}
{!! Form::button("Do something")->color('secondary') !!}
| Param | Type | Default | Description | | ----- | ------ | ------- | ----------- | | $size | string | null | Size name |
// Examples
{!! Form::button("Do something")->size('small') !!}
{!! Form::button("Do something")->size('large') !!}
| Param | Type | Default | Description | | ----- | ------ | ------- | ----------- | | $type | string | null | Type field |
// Examples
// Password field
{!! Form::text('password', 'Your password')->type('password') !!}
// Number field
{!! Form::text('age', 'Your age')->type('number') !!}
// Email field
{!! Form::text('email', 'Your email')->type('email') !!}
| Param | Type | Default | Description | | ----- | ------ | ------- | ----------- | | $name | string | null | Input name |
// Examples
{!! Form::text('text')->name('name') !!}
| Param | Type | Default | Description | | ------ | ------ | ------- | ----------- | | $label | string | null | Input label |
// Examples
{!! Form::text('age')->label('Your age') !!}
| Param | Type | Default | Description | | ------ | ----- | ------- | ----------- | | $value | mixed | null | Input value |
// Example
{!! Form::text('name', 'Your name')->value('Maria') !!}
| Param | Type | Default | Description | | ------- | ------ | ------- | ----------- | | $render | string | null | Render name |
// Examples
// Number field
{!! Form::render('text')->name('age')->label('Your age') !!}