PHPackages                             andersondanilo/modelform - 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. andersondanilo/modelform

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

andersondanilo/modelform
========================

ModelForm is a PHP Form Abstraction for Laravel based on Django Forms and Formset, but completely integrated with the Laravel FormBuilder.

1.0.1(11y ago)201831MITPHP

Since Jan 31Pushed 10y ago3 watchersCompare

[ Source](https://github.com/andersondanilo/modelform)[ Packagist](https://packagist.org/packages/andersondanilo/modelform)[ RSS](/packages/andersondanilo-modelform/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

[![Travis](https://camo.githubusercontent.com/a567c32c1a2181a2d35e6c5831ed106f961899cf44aad5d65950e1e432013923/68747470733a2f2f7472617669732d63692e6f72672f616e646572736f6e64616e696c6f2f6d6f64656c666f726d2e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/a567c32c1a2181a2d35e6c5831ed106f961899cf44aad5d65950e1e432013923/68747470733a2f2f7472617669732d63692e6f72672f616e646572736f6e64616e696c6f2f6d6f64656c666f726d2e7376673f6272616e63683d6d6173746572)[![Code Climate](https://camo.githubusercontent.com/13250f71f53588cdefc168eec6d844753b32f22dd30fea2c7efba741bea2e5e6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616e646572736f6e64616e696c6f2f6d6f64656c666f726d2f6261646765732f6770612e737667)](https://codeclimate.com/github/andersondanilo/modelform)[![Test Coverage](https://camo.githubusercontent.com/ccd07069fb615e43a2c7d8368a2925f12a3cb1ecd045bef4a9c19392bc7ab08b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616e646572736f6e64616e696c6f2f6d6f64656c666f726d2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/andersondanilo/modelform)[![Latest Stable Version](https://camo.githubusercontent.com/06d75bb2f2828366a0fba18077be25f3ace8748a9855002497b964f1426b22cb/68747470733a2f2f706f7365722e707567782e6f72672f616e646572736f6e64616e696c6f2f6d6f64656c666f726d2f762f737461626c652e737667)](https://packagist.org/packages/andersondanilo/modelform)[![Latest Unstable Version](https://camo.githubusercontent.com/cf2f170e05372143b01081178133898751a48ff9b5d368b5646b65cbe574752f/68747470733a2f2f706f7365722e707567782e6f72672f616e646572736f6e64616e696c6f2f6d6f64656c666f726d2f762f756e737461626c652e737667)](https://packagist.org/packages/andersondanilo/modelform)[![License](https://camo.githubusercontent.com/9bf9b2da8b07b1e893a2560197c80c5dcd0e7817b7eeb5b45921a8e8dfd490cb/68747470733a2f2f706f7365722e707567782e6f72672f616e646572736f6e64616e696c6f2f6d6f64656c666f726d2f6c6963656e73652e737667)](https://packagist.org/packages/andersondanilo/modelform)

What is
=======

[](#what-is)

ModelForm is a PHP Form Abstraction for Laravel based on Django Forms and Formset, but completely integrated with the Laravel FormBuilder.

Instalation
===========

[](#instalation)

To get the latest version of ModelForm simply require it in your composer.json file

```
php composer.phar require "andersondanilo/modelform:dev-master"

```

Examples of usage
=================

[](#examples-of-usage)

Simple example: Without model
-----------------------------

[](#simple-example-without-model)

```
// SimpleForm.php
use ModelForm\Form;
use ModelForm\Fields\CharField;
use ModelForm\Fields\IntegerField;

class SimpleForm extends Form
{
    public function makeFields()
    {
        $this->name = new CharField(['label' => 'Name']);
        $this->age = new IntegerField(['label' => 'Age']);
    }
}
```

Instancializing Form

```
$simpleForm = new SimpleForm(['data' => Input::old() ?: Input::all()]);
```

Rendering model in view

```
    {{ $simpleForm->name->label() }}:
    {{ $simpleForm->name->text(['class' => 'form-control']) }}
```

Acessing values after

```
    $name = $simpleForm->name->value;
```

With Model and Validator
------------------------

[](#with-model-and-validator)

```
use ModelForm\Form;
use ModelForm\Fields\CharField;
use ModelForm\Fields\IntegerField;

class SimpleForm extends Form
{
    public function makeFields()
    {
        $this->name = new CharField(['label' => 'Name']);
        $this->age = new IntegerField(['label' => 'Age']);
    }

    public function makeModel()
    {
        return new MyModel();
    }

    public function makeValidator($data)
    {
        return Validator::make($data, [
            'name' => 'required'
        ]);
    }
}
```

You can instancialize without model and then the model is created by form, or start with a already existing model.

```
$model10 = MyModel::find(10);
$form = new SimpleForm(['model' => $model10, 'data' => Input::old() ?: Input::all()]);
```

Validating

```
if(!$simpleForm->isValid()) {
    return Redirect::back()->withErrors($simpleForm->errors())->withInput();
}
```

Saving your model

```
$simpleForm->save();
```

Formsets
--------

[](#formsets)

```
use ModelForm\FormSet;

class SimpleFormSet extends FormSet
{
    public function makeForm($model=null)
    {
        return new SimpleForm(['model'=>$model]);
    }
}
```

Create the empty formset instance:

```
$simpleFormSet = new SimpleFormSet(['data' => Input::old() ?: Input::all());
```

Or create a formset filled with a model relation:

```
$addressFormSet = new AddressFormSet(['relation'=>$customer->addresses(), 'data' => Input::old() ?: Input::all());
```

The validation and saving of formset is the symmetric with form.

```
if(!$addressFormSet->isValid()) {
    return Redirect::back()->withErrors($addressFormSet->errors())->withInput();
}
$addressFormSet->save();
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95.2% 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 ~0 days

Total

2

Last Release

4126d ago

### Community

Maintainers

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

---

Top Contributors

[![andersondanilo](https://avatars.githubusercontent.com/u/5572326?v=4)](https://github.com/andersondanilo "andersondanilo (20 commits)")[![jefersondaniel](https://avatars.githubusercontent.com/u/3521637?v=4)](https://github.com/jefersondaniel "jefersondaniel (1 commits)")

---

Tags

laravelformformbuilderdjangomodelform

### Embed Badge

![Health badge](/badges/andersondanilo-modelform/health.svg)

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

###  Alternatives

[laravie/html

HTML and Form Builders for the Laravel Framework

36184.6k4](/packages/laravie-html)[tomsix/laravel-components-library

A collection of pre-made Blade components for Laravel 7.x and up

613.1k](/packages/tomsix-laravel-components-library)[webup/laravel-form

A Laravel package to help build forms.

147.2k1](/packages/webup-laravel-form)[cornford/bootstrapper

An easy way to intergrate Twitter Bootstrap with Laravel.

232.7k](/packages/cornford-bootstrapper)

PHPackages © 2026

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