PHPackages                             carlosmls1/laraform - 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. carlosmls1/laraform

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

carlosmls1/laraform
===================

HTML and Form Builders for the Laravel Framework from YAML and JSON

1.0.2(8y ago)02MITPHP

Since Mar 29Pushed 5y agoCompare

[ Source](https://github.com/carlosmls1/laraform)[ Packagist](https://packagist.org/packages/carlosmls1/laraform)[ RSS](/packages/carlosmls1-laraform/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (4)Used By (0)

YAML, JSON to html form with validation for laravel
===================================================

[](#yaml-json-to-html-form-with-validation-for-laravel)

Developing rapid forms from YAML and JSON, when large number of input fields will be required as well as frequent addition and deduction of form fields.

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

[](#installation)

```
composer require "carlosmls1/laraform"

```

As `sujan/laraform` package is based on `laravelcollective/html` you have to add your new provider to the providers array of config/app.php:

```
'providers' => [
    // ...
    carlosmls1\LaraForm\ServiceProvider::class,
    Collective\Html\HtmlServiceProvider::class,
    // ...
],

```

Finally, add two class aliases to the aliases array of config/app.php:

```
'aliases' => [
    // ...
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
    // ...
],

```

Then run the command

```
php artisan vendor:publish

```

It will give you a `laraform.css` file in `/css/laraform.css`

Then add `laraform.css` to your master template like

```

```

Usage
-----

[](#usage)

This package has multi purpose usage. You will get all the facilities of `Laravel Collective`as well as facilities of `sujan/laraform` package. We developed this package based on real life scenario.

### Scenario 1

[](#scenario-1)

Say you have to develop a key value store where all of your application settings will reside. The kick here is to add more and more new keys when needed but no code modification will be needed. Then this is the right package for you. All you have to do is to write a YAML or JSON file for your form.

### Scenario 2

[](#scenario-2)

Let's assume the values of your settings will come as a nested object and you have to make a form for the object then this package is a good choice. It will build the form for you within a few minutes all you have to do is write the JSON or YAML file based on the JSON object.

How to Use
----------

[](#how-to-use)

Use it inside form tag in your form like

```
{{ Form::yaml("path/to/file.yml") }}
{{ Form::json("path/to/file.json") }}

```

Laraform support input types `text`, `email`, `password`, `number`, `hidden`, `date`, `file`, `textarea`, `checkbox`, `select`, `radio`, `checkboxlist`, `section`;

### Example 1

[](#example-1)

Let's say you have a `users` table and a `usersmeta` table. In `users` table you will save `name`,`email`, `password` and in `usersmeta` table you want to save `date_of_birth`, `color`, `gender`, `address`, `favourites`, `profile_pic`. Your `yaml` and `json` file will be like below. Where `usermeta` is relation name. Our package will parse the form for you.

### Sample YAML for Example 1

[](#sample-yaml-for-example-1)

```
fields:
    name:
      label: Name
      type: text
      span: left

    email:
      label: Email
      type: email
      span: right

    password:
      label: Password
      type: password
      span: left

    password_confirmation:
      label: Confirm Password
      type: password
      span: right

    metadata:
      label: User Meta
      type: section

    usermeta[date_of_birth]:
      label: Date of Birth
      type: date
      span: left

    usermeta[color]:
      label: Choose Color
      type: select
      span: right
      options:
        "": Choose Color
        red: Red
        green: Green
        blue: Blue

    usermeta[gender]:
      label: Gender
      type: radio
      span: left
      options:
        male: Male
        female: Female
        other: Other

    usermeta[favourites][]:
      label: Favourites
      type: checkboxlist
      span: right
      options:
        cake: Cake
        apple: Apple
        mango: Mango

    usermeta[address]:
      label: Address
      type: textarea

    usermeta[profile_pic]:
      label: Upload profile picture
      type: file

```

### Sample JSON for Example 1

[](#sample-json-for-example-1)

```
{
  "fields": {
    "name": {
      "label": "Name",
      "type": "text",
      "span": "left"
    },
    "email": {
      "label": "Email",
      "type": "email",
      "span": "right"
    },
    "password": {
      "label": "Password",
      "type": "password",
      "span": "left"
    },
    "password_confirmation": {
      "label": "Confirm Password",
      "type": "password",
      "span": "right"
    },
    "metadata": {
      "label": "User Meta",
      "type": "section"
    },
    "usermeta[date_of_birth]": {
        "label": "Date of Birth",
        "type": "date",
        "span": "left"
    },
    "usermeta[color]": {
      "label": "Choose Color",
      "type": "select",
      "span": "right",
      "options": {
        "": "Choose Color",
        "red": "Red",
        "green": "Green",
        "blue": "Blue"
      }
    },
    "usermeta[gender]": {
      "label": "Gender",
      "type": "radio",
      "span": "left",
      "options": {
        "male": "Male",
        "female": "Female",
        "other": "Other"
      }
    },
    "usermeta[favourites][]": {
      "label": "Favourites",
      "type": "checkboxlist",
      "span": "right",
      "options": {
        "cake": "Cake",
        "apple": "Apple",
        "mango": "Mango"
      }
    },
    "usermeta[address]": {
      "label": "Address",
      "type": "textarea"
    },
    "usermeta[profile_pic]": {
      "label": "Upload profile picture",
      "type": "file"
    }
  }
}

```

Here `span` left, right is used to push the input fields to left and right. If you don’t specify span then the span will be full by default.

### Sample create form

[](#sample-create-form)

```
{{ Form::open(['method' => 'POST']) }}
{{ Form::yaml(/path/to/yaml/file) }}
{{ Form::submit('Submit', ['class' => 'form-control']) }}
{{ Form::close() }}

```

#### Html form of sample YAML and JSON.

[](#html-form-of-sample-yaml-and-json)

[![Sample form](https://camo.githubusercontent.com/f323121a1661a69d64aca3c9a6d57fad4bdd57f633659e41ea475c950e737949/68747470733a2f2f692e696d6775722e636f6d2f763158685a69522e706e67)](https://camo.githubusercontent.com/f323121a1661a69d64aca3c9a6d57fad4bdd57f633659e41ea475c950e737949/68747470733a2f2f692e696d6775722e636f6d2f763158685a69522e706e67)

### Form validation rule:

[](#form-validation-rule)

```
$this->validate($request, [
    'name' => 'required',
    'email' => 'required',
    'password' => 'required|confirmed',
    'usermeta.gender' => 'required',
    'usermeta.favourites' => 'required',
    'usermeta.address' => 'required',
    'usermeta.date_of_birth' => 'required',
    'usermeta.color' => 'required',
    'usermeta.profile_pic' => 'required|mimes:jpg,png',
],[
    'usermeta.address.required' => 'The address field is required.',
    'usermeta.favourites.required' => 'The favourites field is required.',
    'usermeta.date_of_birth.required' => 'The date of birth field is required.',
    'usermeta.color.required' => 'The color field is required.',
    'usermeta.gender.required' => 'The gender field is required.',
    'usermeta.profile_pic.required' => 'The profile picture field is required.',
]);

```

#### Html form of sample YAML and JSON with validation message.

[](#html-form-of-sample-yaml-and-json-with-validation-message)

[![Sample form with validation](https://camo.githubusercontent.com/600e5f99e17a4d15d8b09a917c7ce56fbb6d5bd817176ea53ad1380d874b94c0/68747470733a2f2f692e696d6775722e636f6d2f4d54417a6f6c662e706e67)](https://camo.githubusercontent.com/600e5f99e17a4d15d8b09a917c7ce56fbb6d5bd817176ea53ad1380d874b94c0/68747470733a2f2f692e696d6775722e636f6d2f4d54417a6f6c662e706e67)

The YAML and JSON files work for both create and edit page, all you have to do is to pass the model instance or JSON object.

#### Sample edit form for the above example.

[](#sample-edit-form-for-the-above-example)

```
{{ Form::model($model, ['method' => 'POST']) }}
{{ Form::yaml(/path/to/yaml/file) }}
{{ Form::submit('Submit', ['class' => 'form-control']) }}
{{ Form::close() }}

```

Here variable `$model` is model instance or JSON object like below.

Sample JSON object
------------------

[](#sample-json-object)

```
{
    "name": "John Doe",
    "email": "john@example.com",
    "usermeta": {
        "date_of_birth": "2018-04-19",
        "color": "green",
        "gender": "male",
        "favourites": [
            "cake",
            "mango"
        ],
        "address": "No where"
    }
}

```

### Sample edit form of the above JSON object

[](#sample-edit-form-of-the-above-json-object)

[![Sample edit form](https://camo.githubusercontent.com/e5ba66acfd3517a0fa87db4b5bd3ebb5ca772ce4b9b4f8f1d4ee1a4c8618c66f/68747470733a2f2f692e696d6775722e636f6d2f534868636e4a682e706e67)](https://camo.githubusercontent.com/e5ba66acfd3517a0fa87db4b5bd3ebb5ca772ce4b9b4f8f1d4ee1a4c8618c66f/68747470733a2f2f692e696d6775722e636f6d2f534868636e4a682e706e67)

### Sample edit form with validation message

[](#sample-edit-form-with-validation-message)

[![Sample edit form with validation](https://camo.githubusercontent.com/0ef634d49a4c3688230f3f330215bc54bfe7abff2931518f4d5e68002252785f/68747470733a2f2f692e696d6775722e636f6d2f597551394c77792e706e67)](https://camo.githubusercontent.com/0ef634d49a4c3688230f3f330215bc54bfe7abff2931518f4d5e68002252785f/68747470733a2f2f692e696d6775722e636f6d2f597551394c77792e706e67)

The `yaml` and `json` file for the above object will be `#Sample 1`'s two files.

### Form validation

[](#form-validation)

You have to use laravel's form validation methodology. The error message handling is included in the package. So you don't have to write code for showing error messages. The message will be shown below the input field marked red.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 88.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 ~4 days

Total

3

Last Release

2957d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c3d887e658e3f9ee25176e6c3654a0629d25650374c756f32467c115d3bb1a4?d=identicon)[carlosmls1](/maintainers/carlosmls1)

---

Top Contributors

[![sujancse](https://avatars.githubusercontent.com/u/16623485?v=4)](https://github.com/sujancse "sujancse (16 commits)")[![thedevsujan](https://avatars.githubusercontent.com/u/49937081?v=4)](https://github.com/thedevsujan "thedevsujan (2 commits)")

### Embed Badge

![Health badge](/badges/carlosmls1-laraform/health.svg)

```
[![Health](https://phpackages.com/badges/carlosmls1-laraform/health.svg)](https://phpackages.com/packages/carlosmls1-laraform)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[endroid/qr-code-bundle

Endroid QR Code Bundle

32110.6M17](/packages/endroid-qr-code-bundle)[webuni/front-matter

Front matter parser and dumper for PHP

41264.9k11](/packages/webuni-front-matter)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

1432.0k](/packages/symfony-ux-toolkit)[iq2i/storia-bundle

UI Storia bundle

144.6k](/packages/iq2i-storia-bundle)

PHPackages © 2026

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