Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravelforms Laravel Package

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.

View on GitHub
Deep Wiki
Context7

laravelforms

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.

Supported form input components

  • Checkbox
  • Color
  • Date
  • DateTime
  • Email
  • Hidden
  • Number
  • Password
  • Phone
  • Radio
  • Select
  • Select Multiple
  • Text
  • Textarea
  • Url
  • File
  • Time
  • Month

Licence

MIT

Documentation & usage

Documentation is available on package website https://webroad.dev/packages/laravelforms/documentation

Packagist: https://packagist.org/packages/michalkortas/laravelforms

Support

Laravel 7 and 8 are only supported versions

Installation

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

Example

Simple Text input

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>

Simple Select input

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>

Using Laravel Models

You can also use Laravel Models to fill every inputs.

Simple 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>

Inputs with multiple values (eg. select multiple, checkbox)

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" />
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony