PHPackages                             nickwest/form-maker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. nickwest/form-maker

ActiveLibrary[Templating &amp; Views](/categories/templating)

nickwest/form-maker
===================

Create Bulma compatible forms and tables directly from Eloquent Models and Collections

v5.5.1(8y ago)37842[18 issues](https://github.com/nickwest/laravel-FormMaker/issues)MITPHPPHP &gt;=7.0

Since Apr 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/nickwest/laravel-FormMaker)[ Packagist](https://packagist.org/packages/nickwest/form-maker)[ RSS](/packages/nickwest-form-maker/feed)WikiDiscussions 5.5.x Synced 1w ago

READMEChangelogDependencies (7)Versions (14)Used By (0)

Laravel FormMaker
=================

[](#laravel-formmaker)

Laravel FormMaker was created by and is maintained by [Nick West](https://github.com/nickwest). It was created to minimize the time and effort required to create simple HTML forms to support Eloquent Model CRUD functionality.

Laravel FormMaker includes a trait for Eloquent models that can be used to automatically generate a form view based on the underlying table structure supporting the Eloquent model. Forms created this way can be fully customized. Basic validation is included and can be expanded upon easily.

As of version 5.5 Laravel FormMaker can be easily themed to support various front-end css/js frameworks and includes the necessary blade templates to support the [Bulma](https://bulma.io) framework out of the box.

Installation
------------

[](#installation)

Laravel FormMaker requires PHP 7+. This particular version supports Laravel 5.5. It might function on older versions, but it was not tested on &lt; 5.5.

To get the latest version you need only require the package via Composer.

```
Composer require nickwest/form-maker

```

FormMaker supports [Laravel Auto-Discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518). It shouldn't be necessary with Laravel 5.5+, but to manually add the package the following providers should be added in your config/app.php:

```
Nickwest\FormMaker\FormMakerServiceProvider::class,
Nickwest\FormMaker\bulma\FormMakerBulmaThemeServiceProvider::class

```

Usage
-----

[](#usage)

### Adding functionality to an Eloquent Model

[](#adding-functionality-to-an-eloquent-model)

```
class Sample extends Model{
    use FormTrait;

    protected $table = 'sample';

    // Options for setting up the form:

    // OPTION 1: Create a method in the model that will be called by the controller

    // The method name doesn't matter, it's up to you.
    public function prepareForm()
    {
        // Set a default Form Field label postfix
        $this->label_postfix = ':';

        // This comes from the FormTrait. It generates form field data by looking at
        // the model's table columns
        $this->generateFormData();

        // Use a custom theme for the generated markup
        $this->Form()->setTheme(new \Nickwest\FormMaker\bulma\Theme());

        // By Default all fields will be displayed

        // We can set specific fields to be displayed by the form.
        // The order here dictates the order the fields will show on the form
        // $this->Form()->setDisplayFields( array(
        //     'email',
        //     'attendance_date',
        //     'placard_color',
        //     'photograph',
        //     'phone_number',
        //     'link_to_website',
        //     'meal_choice',
        //     'fruits_they_like',
        //     'plus_one',
        // ));

        // Or we can remove only selected display fields and the rest will
        // display in the same order they appear in the underlying table.
        $this->Form()->removeDisplayFields([
            'id',
            'created_at',
            'updated_at',
        ]);

        // Set field types for fields that aren't just default types
        $this->Form()->setTypes([
            'email' => 'email',
            'attendance_date' => 'date',
            'placard_color' => 'color',
            'photograph' => 'file',
            'phone_number' => 'tel',
            'link_to_website' => 'url',
            'meal_choice' => 'select',
            'fruits_they_like' => 'checkbox',
            'plus_one' => 'radio', // Yes/No enum in database
        ]);

        // Fields set up as Enums in the database will automatically have enum
        // options available, but enums are not requires for multiple choice fields

        $this->Form()->fruits_they_like->setOptions([
            'banana' => 'Banana',
            'strawberry' => 'Strawberry',
            'apple' => 'Apple',
            'mango' => 'Mango',
            'passion Fruit' => 'Passion Fruit',
            'orange' => 'Orange',
            'kiwi' => 'Kiwi',
            'pear' => 'Pear',
            'pineapple' => 'Pineapple'
        ]);

        $this->Form()->meal_choice->setOptions([
            'cheap_meal' => 'Chicken',
            'average_meal' => 'Beef',
            'expensive_meal' => 'Lobster',
        ]);

        // Make it a multi-select field
        $this->Form()->meal_choice->multiple = true;

        // Set examples to show up below the field
        $this->Form()->setExamples([
            'email' => 'ex: example@example.com',
        ]);

        // Set a pattern (used to add pattern="" attribute to field)
        $this->Form()->phone_number->attributes->pattern = '\\d{3}[\\-]\\d{3}[\\-]\\d{4}';

        // Set a placeholder (similar to example, but uses placeholder attribute)
        $this->Form()->phone_number->attributes->placeholder = '123-456-7890';

        // Set some validation (This uses Laravel's Validator facade:
        // https://laravel.com/docs/5.5/validation
        $this->validation_rules = [
            'email' => 'email|max:256',
            'fruits_they_like' => 'in:'.implode(',', array_keys($this->Form()->fruits_they_like->options)),
            'meal_choice' => 'in:'.implode(',', array_keys($this->Form()->meal_choice->options)),
            // you can add an validation rules you want here.
        ];

        // Include a delete button?
        $this->Form()->allow_delete = false;

    }

    // OPTION 2: Do all of this in the controller. You would choose this
    // method if your form is likely to look different at different routes.
    // If it will always be the same having a method to call is less repetition.
    // You can also modify the form after calling the method above, so a mix of
    // the two works as well.

    // Option 3: Do this in the constructor. I would advise against doing this
    // in the constructor since generateFormData() runs a query to the get the
    // table structure.

}

```

### The Controller

[](#the-controller)

```
    // The GET route for the form page
    public function getForm(Request $request, int $id=0)
    {
        $blade_data = [
            'page_title' => 'Sample Form',
            'whatever_else' => 'Any data your base view need can be passed through',
        ];

        // Find the Model if an ID is passed in, otherwise start a new one.
        $Sample = Sample::findOrNew($id);

        // prepare the form as described in the Model method above
        $Sample->prepareForm();

        // This is a FormMaker trait method. It populates form values based on
        // data in the current Model and by defaults and other settings
        // configured in the step before.
        $Sample->setAllFormValues();

        // If there's old request data, set it.
        if($request->old())
        {
            $Sample->setPostValues($request->old());
        }

        // Make a view that extends 'base_layout'
        return $Sample->getFormView($blade_data, 'base_layout', 'content');
    }

```

Misc
----

[](#misc)

FormMaker doesn't need to be used by the trait. The Form and Field classes can be used standalone as well. Instead of automatically generating form fields, they will need to be manually declared.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 96.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~204 days

Recently: every ~397 days

Total

14

Last Release

1405d ago

Major Versions

4.0.1.x-dev → v5.3.02016-10-05

5.3.x-dev → 9.0.x-dev2022-07-13

PHP version history (4 changes)5.0.x-devPHP &gt;=5.4.0

v5.2PHP &gt;=5.5.0

v5.5.0PHP &gt;=7.0

9.0.x-devPHP ^8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/d49b88608b2ef4fca8fd1ddf77d4b27151cdf7363b06a69bbf60d1c95bbecc09?d=identicon)[nickwest](/maintainers/nickwest)

---

Top Contributors

[![nickwest](https://avatars.githubusercontent.com/u/634790?v=4)](https://github.com/nickwest "nickwest (156 commits)")[![NgGeorge](https://avatars.githubusercontent.com/u/14927658?v=4)](https://github.com/NgGeorge "NgGeorge (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nickwest-form-maker/health.svg)

```
[![Health](https://phpackages.com/badges/nickwest-form-maker/health.svg)](https://phpackages.com/packages/nickwest-form-maker)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
