PHPackages                             wscore/formmodel - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. wscore/formmodel

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

wscore/formmodel
================

component for HTML form and validation model.

0.1.1(6y ago)01[3 issues](https://github.com/WScore/FormModel/issues)MITPHP

Since May 31Pushed 6y ago1 watchersCompare

[ Source](https://github.com/WScore/FormModel)[ Packagist](https://packagist.org/packages/wscore/formmodel)[ RSS](/packages/wscore-formmodel/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

FormModel
=========

[](#formmodel)

a framework agnostic component for building HTML forms and validations.

works for;

- various input types, such as date, textarea, choices,
- incorporates another form,
- incorporates one-to-many forms, and
- defaults to output html forms for `Bootstrap 4`.

> inspired by `Symfony/form` component.

### Installation

[](#installation)

t.b.w.

### Demo

[](#demo)

clone this repository,

```
git clone https://github.com/asaokamei/FormModel
cd FormModel
composer install

```

run the demo script,

```
cd demo
php -S localhost:8000

```

then, browse the above url.

How To
------

[](#how-to)

### Create a FormModel

[](#create-a-formmodel)

create a form model using `FormBuilder`.

```
use WScore\FormModel\FormBuilder;

$builder = FormBuilder::create();
$book = $builder->formModel('book', [
        'label' => 'Book Information',
    ]);
```

### Add Elements

[](#add-elements)

add elements for the form model, `$book`.

```
use WScore\FormModel\Type\TextAreaType;
use WScore\FormModel\Type\TextType;

$book
    ->add('title', TextType::class, [
        'label' => 'Book Title',
    ])
    ->add('abstract', TextAreaType::class, [
        'label' => 'Abstracts',
        'attributes' => [
            'style' => 'height: 5em;',
        ]
    ]);
```

usage: `add($name, $typeName, $options);`,

- `$name`: name of the element,
- `$typeName`: class name of the element type,
- `$options`: an array of options.

### Validate Input

[](#validate-input)

to validate input values, such as form,

```
$validation = $book->createValidation($_POST);
if ($validation->isValid()) {
    $data = $validation->getData();
} else {
    $data = []; // just in case...
}
```

### Show HTML Form

[](#show-html-form)

to show HTML forms, create a view, `$view`, as below.

```
$view = $book->createView();
```

or, validate inputs then create a view.

```
$validation = $book->createValidation($_POST);
$view = $validation->createView();
```

once a view is created, show html forms as such.

```

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~35 days

Total

2

Last Release

2504d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ed783829e6fa0bd4b0def8c04ccfdfb2fc99f9e61e4a9470acad9e5abc5fcac?d=identicon)[asaokamei](/maintainers/asaokamei)

---

Top Contributors

[![asaokamei](https://avatars.githubusercontent.com/u/747030?v=4)](https://github.com/asaokamei "asaokamei (155 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wscore-formmodel/health.svg)

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M450](/packages/nette-forms)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)

PHPackages © 2026

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