A simple library to make Laravel Blade forms faster and easier
Licence: MIT
Version: 1.x
GitHub: github.com/michalkortas/laravelforms
Packagist: packagist.org/packages/michalkortas/laravelforms
composer require michalkortas/larvelforms
Register new ServiceProvider (only if not exists - Laravel register it automatically, but who knows?) in config/app.php
michalkortas\LaravelForms\LaravelFormsServiceProvider::class
Laravel 7 & 8 are only supported version at this time.
You can also use Laravel Models to fill every inputs.
<x-form-text :model="$model" name="translation" label="String translation" />
Object key is set by "name" attribute. If you want to change it, use "model-key" attribute instead. This can be also relation path (separator: ".""), eg. firstrelation.second.id
<x-form-text :model="$model" model-key="otherkey" name="translation" label="String translation" />
If you want to get data from your Pivot relation to check multiple options, pass via model-key attribute relation path to related table. Last part of this path is a table field, that should be use to verify checked/selected state.
<x-form-checkbox :model="$model" model-key="departments.id" :options="$departments" label="Select department" />
<x-form-text label="This is simple text label" name="text-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | Ooops... |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-email label="This is simple email input" name="email-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | Ooops... |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-phone label="This is simple phone input" name="email-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | Ooops... |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-date label="This is simple date input" name="date-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | date | null | 2024-11-24 |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-date-time label="This is simple datetime input" name="datetime-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | datetime | null | 2024-11-24T02:05 |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-number min="0" step="1" label="This is simple number label" name="number-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | number | null | 25 |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-textarea label="This is simple text label" name="textarea-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | Ooops... |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
array:3 [
1 => "one"
2 => "two"
3 => "three"
]
<x-form-select label="This is simple text label" name="select-input" value="2" :options="$options" />
{#310
+"0": {#319
+"id": 4
+"name": "four"
}
+"1": {#326
+"id": 5
+"name": "five"
}
}
<x-form-select label="This is simple text label" name="select-input" value="4" :options="$options" />
{#315
+"0": {#330
+"item_id": 4
+"item_name": "four"
}
+"1": {#328
+"item_id": 5
+"item_name": "five"
}
}
<x-form-select label="This is simple text label" name="select-input" value="4" option-value-key="item_id" option-text-key="item_name" :options="$options" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | 5 |
empty | boolean | false | true |
empty-option-value | text | null | none |
empty-option-text | text | null | Select from list |
option-value-key | text | id | item_id |
option-text-key | text | name | item_name |
option-text-separator | text | (space " ") | -.- |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
You should pass values as array via :value=""
attribute.
array:2 [
0 => 1
1 => 3
]
array:3 [
1 => "one"
2 => "two"
3 => "three"
]
<x-form-select-multiple label="This is simple text label" name="select-input" :value="$values" :options="$options" />
{#283
+"0": {#351
+"id": 4
+"name": "four"
}
+"1": {#362
+"id": 5
+"name": "five"
}
}
<x-form-select-multiple label="This is simple text label" name="select-input" :value="$values" :options="$options" />
{#342
+"0": {#363
+"item_id": 4
+"item_name": "four"
}
+"1": {#347
+"item_id": 5
+"item_name": "five"
}
}
<x-form-select-multiple label="This is simple text label" name="select-input" :value="$values" option-value-key="item_id" option-text-key="item_name" :options="$options" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | 5 |
empty | boolean | false | true |
empty-option-value | text | null | none |
empty-option-text | text | null | Select from list |
option-value-key | text | id | item_id |
option-text-key | text | name | item_name |
option-text-separator | text | (space " ") | -.- |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
array:3 [
1 => "one"
2 => "two"
3 => "three"
]
<x-form-radio label="This is simple text label" name="radio1-input" value="2" :options="$options" />
{#327
+"0": {#379
+"id": 4
+"name": "four"
}
+"1": {#386
+"id": 5
+"name": "five"
}
}
<x-form-radio label="This is simple text label" name="radio2-input" value="4" :options="$options" />
{#374
+"0": {#390
+"item_id": 4
+"item_name": "four"
}
+"1": {#388
+"item_id": 5
+"item_name": "five"
}
}
<x-form-radio label="This is simple text label" name="radio3-input" value="4" option-value-key="item_id" option-text-key="item_name" :options="$options" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | 5 |
empty | boolean | false | true |
inline | boolean | false | true |
empty-option-value | text | null | none |
empty-option-text | text | null | Select from list |
option-value-key | text | id | item_id |
option-text-key | text | name | item_name |
option-text-separator | text | (space " ") | -.- |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
You should pass values as array via :value=""
attribute.
array:2 [
0 => 1
1 => 3
]
array:3 [
1 => "one"
2 => "two"
3 => "three"
]
<x-form-checkbox label="This is simple text label" name="checkbox1-input" :value="$values" :options="$options" />
{#383
+"0": {#411
+"id": 4
+"name": "four"
}
+"1": {#417
+"id": 5
+"name": "five"
}
}
<x-form-checkbox label="This is simple text label" name="checkbox2-input" :value="$values" :options="$options" />
{#407
+"0": {#422
+"item_id": 4
+"item_name": "four"
}
+"1": {#420
+"item_id": 5
+"item_name": "five"
}
}
<x-form-checkbox label="This is simple text label" name="checkbox3-input" :value="$values" option-value-key="item_id" option-text-key="item_name" :options="$options" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | 5 |
empty | boolean | false | true |
inline | boolean | false | true |
empty-option-value | text | null | none |
empty-option-text | text | null | Select from list |
option-value-key | text | id | item_id |
option-text-key | text | name | item_name |
option-text-separator | text | (space " ") | -.- |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-color label="This is simple text label" name="color-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | color | null | #000000 |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-password label="This is simple text label" name="password-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | password |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-url label="This is simple text label" name="url-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | text | null | Ooops... |
placeholder | text | null | Write something |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
<x-form-boolean label="This is simple text label" name="text-input" value="1" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | boolean | false | true |
value-false | text | false (bool) | no |
value-true | text | true (bool) | yes |
text-false | text | No | Nope |
text-true | text | Yes | Yeah |
toggler-class | text | btn-secondary | btn-light |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
class-true | text | state-true | new-true-class |
class-false | text | state-false | new-false-class |
<x-form-nullean label="This is simple text label" name="text-input" value="" />
Parameter | Value format | Default | Example |
---|---|---|---|
id | text | null | text-input |
name | text | null | text-input |
label | text | null | This is simple text label |
value | boolean | false | true |
value-false | text | false (bool) | no |
value-true | text | true (bool) | yes |
value-null | text | null | idk |
text-false | text | No | Nope |
text-true | text | Yes | Yeah |
text-null | text | ? | Hmm? |
toggler-class | text | btn-secondary | btn-light |
group-class | text | null | additional-group-class |
label-class | text | null | additional-label-class |
feedback-class | text | null | additional-feedback-class |
model | object | [] | Model::find(1) |
model-key | text | null | object_id |
class | text | null | additional-input-class |
class-true | text | state-true | new-true-class |
class-false | text | state-false | new-false-class |
class-null | text | state-null | new-null-class |