laravel-form-builder is a free, open source forms & surveys project written in PHP and released under MIT. It has 1,714 GitHub stars, 305 forks and 115 open issues, and was last pushed 30 days ago. On this registry it ranks #6 of 12 tracked projects in Forms & Surveys, with 5 head-to-head comparisons available.

What is laravel-form-builder?

What it is

laravel-form-builder is PHP package for Laravel 5+ form building. It gives form classes. It uses Laravel FormBuilder class. It is inspired by Symfony form builder. It lives in Laravel ecosystem. It sits in Business Software / Forms & Surveys category. It is MIT licensed. It has 1714 stars, 305 forks, and 115 open issues. Repo age is 12 years. Last push was 2026-08-19T15:11:50Z. Detailed documentation lives at kristijanhusak.github.io/laravel-form-builder. A changelog is available.

Laravel form code can repeat. This package creates one form class per form. It defines fields, rules, labels, values, and form options. It connects controller create and store actions. It renders forms with Bootstrap 3 by default. It helps modify and reuse forms. It adds laravelcollective/html and loads Form and Html aliases if they do not exist. It can instantiate empty form without fields by skipping --fields. It can redirect invalid forms with redirectIfNotValid.

Key capabilities

  • Creates reusable form classes through php artisan make:form Forms/SongForm --fields="name:text, lyrics:textarea, publish:checkbox".
  • Defines fields with types and validation rules, such as required|min:5 and max:5000.
  • Handles validation and errors with $form->isValid(), $form->getErrors(), and redirect back with input.
  • Binds submitted values to model properties with $form->getFieldValues().
  • Installs through Composer as kris/laravel-form-builder.
  • Registers Kris\LaravelFormBuilder\FormBuilderServiceProvider::class and FormBuilder facade.
  • Supports Bootstrap 3 by default; Bootstrap 4 needs laravel-form-builder-bs4.

Who uses it and how

  • Laravel developers add form classes under app/Forms.
  • Controllers create forms with $formBuilder->create(Forms/SongForm::class, [ 'method' => 'POST', 'url' => route('song.store') ]).
  • Store actions validate submitted forms before saving data.
  • Teams reuse one form class across create and edit views.
  • Apps using Laravel 4 use separate laravel4-form-builder; apps using Bootstrap 4 use laravel-form-builder-bs4.

Getting started

Run composer require kris/laravel-form-builder, add service provider and facade in config/app.php, then create form class with php artisan make:form; if upgrading past 1.6.*, rename default_value to value. If you want empty form, skip --fields parameter.

When to use it — and when not to

Use it when Laravel 5+ app needs class-based form definitions, validation, and reusable field setup. Do not use it for Laravel 4, because that needs laravel4-form-builder; do not rely on it for Bootstrap 4 styling, because that needs laravel-form-builder-bs4. Self-hosters must operate Laravel app and Composer dependencies; 115 open issues are listed, and no hosted option is given.

project readme (upstream, from github) — read inline

Build Status Coverage Status Total Downloads Latest Stable Version License

Laravel 5 form builder

Join the chat at https://gitter.im/kristijanhusak/laravel-form-builder

Form builder for Laravel 5 inspired by Symfony's form builder. With help of Laravels FormBuilder class creates forms that can be easy modified and reused. By default it supports Bootstrap 3.

Laravel 4

For Laravel 4 version check laravel4-form-builder.

Bootstrap 4 support

To use bootstrap 4 instead of bootstrap 3, install laravel-form-builder-bs4.

Upgrade to 1.6

If you upgraded to >1.6.* from 1.5.* or earlier, and having problems with form value binding, rename default_value to value.

More info in changelog.

Documentation

For detailed documentation refer to https://kristijanhusak.github.io/laravel-form-builder/.

Changelog

Changelog can be found here.

Installation

Using Composer

composer require kris/laravel-form-builder

Or manually by modifying composer.json file:

{
    "require": {
        "kris/laravel-form-builder": "1.*"
    }
}

And run composer install

Then add Service provider to config/app.php

    'providers' => [
        // ...
        Kris\LaravelFormBuilder\FormBuilderServiceProvider::class
    ]

And Facade (also in config/app.php)

    'aliases' => [
        // ...
        'FormBuilder' => Kris\LaravelFormBuilder\Facades\FormBuilder::class
    ]

Notice: This package will add laravelcollective/html package and load aliases (Form, Html) if they do not exist in the IoC container.

Quick start

Creating form classes is easy. With a simple artisan command:

php artisan make:form Forms/SongForm --fields="name:text, lyrics:textarea, publish:checkbox"

Form is created in path app/Forms/SongForm.php with content:

<?php

namespace App\Forms;

use Kris\LaravelFormBuilder\Form;
use Kris\LaravelFormBuilder\Field;

class SongForm extends Form
{
    public function buildForm()
    {
        $this
            ->add('name', Field::TEXT, [
                'rules' => 'required|min:5'
            ])
            ->add('lyrics', Field::TEXTAREA, [
                'rules' => 'max:5000'
            ])
            ->add('publish', Field::CHECKBOX);
    }
}

If you want to instantiate empty form without any fields, just skip passing --fields parameter:

php artisan make:form Forms/PostForm

Gives:

<?php

namespace App\Forms;

use Kris\LaravelFormBuilder\Form;

class PostForm extends Form
{
    public function buildForm()
    {
        // Add fields here...
    }
}

After that instantiate the class in the controller and pass it to view:

<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Kris\LaravelFormBuilder\FormBuilder;

class SongsController extends BaseController {

    public function create(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class, [
            'method' => 'POST',
            'url' => route('song.store')
        ]);

        return view('song.create', compact('form'));
    }

    public function store(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class);

        if (!$form->isValid()) {
            return redirect()->back()->withErrors($form->getErrors())->withInput();
        }

        // Do saving and other things...
    }
}

Alternative example:

<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Kris\LaravelFormBuilder\FormBuilder;
use App\Forms\SongForm;

class SongsController extends BaseController {

    public function create(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(SongForm::class, [
            'method' => 'POST',
            'url' => route('song.store')
        ]);

        return view('song.create', compact('form'));
    }

    public function store(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(SongForm::class);

        if (!$form->isValid()) {
            return redirect()->back()->withErrors($form->getErrors())->withInput();
        }

        // Do saving and other things...
    }
}

If you want to store a model after a form submit considerating all fields are model properties:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Kris\LaravelFormBuilder\FormBuilder;
use App\SongForm;

class SongFormController extends Controller
{
    public function store(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class);
        $form->redirectIfNotValid();
        
        SongForm::create($form->getFieldValues());

        // Do redirecting...
    }

You can only save properties you need:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Kris\LaravelFormBuilder\FormBuilder;
use App\SongForm;

class SongFormController extends Controller
{
    public function store(FormBuilder $formBuilder, Request $request)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class);
        $form->redirectIfNotValid();
        
        $songForm = new SongForm();
        $songForm->fill($request->only(['name', 'artist'])->save();

        // Do redirecting...
    }

Or you can update any model after form submit:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Kris\LaravelFormBuilder\FormBuilder;
use App\SongForm;

class SongFormController extends Controller
{
    public function update(int $id, Request $request)
    {
        $songForm = SongForm::findOrFail($id);

        $form = $this->getForm($songForm);
        $form->redirectIfNotValid();

        $songForm->update($form->getFieldValues());

        // Do redirecting...
    }

Create the routes

// app/Http/routes.php
Route::get('songs/create', [
    'uses' => 'SongsController@create',
    'as' => 'song.create'
]);

Route::post('songs', [
    'uses' => 'SongsController@store',
    'as' => 'song.store'
]);

Print the form in view with form() helper function:

<!-- resources/views/song/create.blade.php -->

@extends('app')

@section('content')
    {!! form($form) !!}
@endsection

Go to /songs/create; above code will generate this html:

<form method="POST" action="http://example.dev/songs">
    <input name="_token" type="hidden" value="FaHZmwcnaOeaJzVdyp4Ml8B6l1N1DLUDsZmsjRFL">
    <div class="form-group">
        <label for="name" class="control-label">Name</label>
        <input type="text" class="form-control" id="name">
    </div>
    <div class="form-group">
        <label for="lyrics" class="control-label">Lyrics</label>
        <textarea name="lyrics" class="form-control" id="lyrics"></textarea>
    </div>
    <div class="form-group">
        <label for="publish" class="control-label">Publish</label>
        <input type="checkbox" name="publish" id="publish">
    </div>
</form>

Or you can generate forms easier by using simple array

createByArray([
                        [
                            'name' => 'name',
                            'type' => Field::TEXT,
                        ],
                        [
                            'name' => 'lyrics',
                            'type' => Field::TEXTAREA,
                        ],
                        [
                            'name' => 'publish',

readme truncated — read the full docs on github

Frequently asked questions

Is laravel-form-builder free to use?

laravel-form-builder is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does laravel-form-builder do?

Laravel Form builder for version 5+!

What is laravel-form-builder written in?

laravel-form-builder is primarily written in PHP. Its source is publicly available at https://github.com/kristijanhusak/laravel-form-builder, and it has 1,714 GitHub stars.