michalkortas/laravelforms
Blade form components for Laravel 7–8 that generate Bootstrap-styled inputs fast, with built-in validation error support. Includes text, select, textarea, checkbox, radio, file, date/time, color, and more, with easy model binding for values.
A simple library to make Laravel Blade forms faster and easier. Every component returns full form control with Bootstrap CSS classes. Out of the box supports Laravel validation errors.
MIT
Documentation is available on package website https://webroad.dev/packages/laravelforms/documentation
Packagist: https://packagist.org/packages/michalkortas/laravelforms
Laravel 7 and 8 are only supported versions
composer require michalkortas/laravelforms
Register new ServiceProvider (only if not exists - Laravel register it automatically, but who knows?) in config/app.php
michalkortas\LaravelForms\LaravelFormsServiceProvider::class
Inserted Text component
<x-form-text label="This is simple text label" name="text-input" value="" />
HTML output:
<div class="form-group">
<label>This is simple text label</label>
<input value="" type="text" name="text-input" class="form-control" placeholder="This is simple text label">
</div>
Inserted Select component
$options = [1=>"one", 2=>"two", 3=>"three"];
<x-form-select label="This is simple text label" name="select-input" value="2" :options="$options" />
HTML output:
<div class="form-group">
<label>This is simple text label</label>
<select name="select-input" class="form-control">
<option value="1">one</option>
<option selected="selected" value="2">two</option>
<option value="3">three</option>
</select>
</div>
You can also use Laravel Models to fill every inputs.
<x-form-text :model="$model" name="translation" label="String translation" />
HTML output:
<div class="form-group ">
<label>String translation</label>
<input type="text" name="translation" value="First value" class="form-control" placeholder="String translation">
</div>
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" />
HTML output:
<div class="form-group ">
<label>String translation</label>
<input type="text" name="translation" value="Other value" class="form-control" placeholder="String translation">
</div>
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" />
How can I help you explore Laravel packages today?