brainfab / laravel-form by brainfab

Use Symfony Form component with Laravel framework
Package Data
Maintainer Username: brainfab
Maintainer Contact: (Max Kovpak)
Package Create Date: 2017-01-16
Package Last Update: 2017-01-27
Home Page:
Language: HTML
License: MIT
Last Refreshed: 2021-02-27 15:02:07
Package Statistics
Total Downloads: 13
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 2
Total Open Issues: 3

Use Symfony Form component with Laravel framework

Latest Stable Version Total Downloads Latest Unstable Version License Code Climate

Under construction


Require this package with composer:

composer require brainfab/laravel-form

After updating composer, add the ServiceProvider to the providers array in config/app.php


Add the Facade to the aliases array in config/app.php

'FormFactory' => Brainfab\LaravelForm\Facades\FormFactory::class,

(optional) Copy the package config to your local config with the publish command:

php artisan vendor:publish --tag=config

(optional) Copy the package views to your local views/vendor folder with the publish command:

php artisan vendor:publish --tag=views


Generate form class: php artisan make:form 'App\Forms\UserForm'

Usage example



namespace App\Forms;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class UserForm extends AbstractType
     * {@inheritdoc}
    public function buildForm(FormBuilderInterface $builder, array $options)
        $builder->add('name', TextType::class, [
            'rules' => 'required|min:6',
            'label' => 'Name'

        $builder->add('email', EmailType::class, [
            'rules' => 'required|email',
            'label' => 'Email'

        $builder->add('save_btn', SubmitType::class, [
            'label' => 'Save'

     * @param OptionsResolver $resolver
    public function configureOptions(OptionsResolver $resolver)
        //set default options



namespace App\Http\Controllers;

use App\Forms\UserForm;
use Brainfab\LaravelForm\Controller\LaravelForm;
use App\User;
use Illuminate\Http\Request;

class UserController extends Controller
    use LaravelForm;

    public function index(Request $request)
        $user = new User();

        $form = $this->createForm(TestForm::class, $user);

        if ($request->isMethod('post')) {
            //submit request

            if ($form->isValid()) {

        return view('users', [
            'form' => $form->createView()


<!doctype html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">