PHPackages                             franzwegener/quantumforms - 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. franzwegener/quantumforms

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

franzwegener/quantumforms
=========================

QuantumForms is a customizable FormBuilder that uses the same validators in frontend and backend.

161PHP

Since Aug 19Pushed 9y ago2 watchersCompare

[ Source](https://github.com/FranzWegener/QuantumForms)[ Packagist](https://packagist.org/packages/franzwegener/quantumforms)[ RSS](/packages/franzwegener-quantumforms/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

QuantumForms
============

[](#quantumforms)

[![Github made-in](https://camo.githubusercontent.com/4b45c2ad2d17ce733bdac58c6734bb9a3a29206d8e4ddf351f3d98aee16b235e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6164655f496e2d4265726c696e2d677265656e2e737667)](#) [![Build Status](https://camo.githubusercontent.com/3f43143b6c76dc6fc4b83c68e4e713818cda250c18502cda2f20f0250cd9b816/68747470733a2f2f7472617669732d63692e6f72672f4672616e7a576567656e65722f5175616e74756d466f726d732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/FranzWegener/QuantumForms) [![Coverage Status](https://camo.githubusercontent.com/a504dccbfa015a58cde576ba12d1e4b07b1324efa2b6cc36f7c8bace6c47869c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4672616e7a576567656e65722f5175616e74756d466f726d732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/FranzWegener/QuantumForms?branch=master)

QuantumForms is an easily customizable FormBuilder that uses the same validators in frontend and backend.

Features
--------

[](#features)

- Standalone: no dependencies, so it is framework independent and no dependency management is needed
- Easy to use and extend:
    - add a validator by adding a class to the Validators directory (all validators include the frontend and backend part)
    - add a Javascript Form Error handler by adding a js-closure to JsErrorNotifiers
    - add new type of FormElements by adding a class to the FormElementsDirectory
    - exchange the Form-builder itself by adding to the Forms directory
- low bandwith (only the validators you use are transmitted to client-side)
- PSR4

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

[](#installation)

Installing QuantumForms is incredibly easy with composer

```
composer require franzwegener/quantumforms
```

Alternatively, if your project doesn't use `composer` (QuantumForms doesn't have any dependencies, so composer isn't required!), you can simply include and register the autoloader.

```
require_once $quantumFormsRootPath.'/Autoloader.php';
$loader = new Autoloader();
$loader->register();
```

Usage
-----

[](#usage)

#### Form Definition

[](#form-definition)

1). Instantiate your form

```
$form = new Form('GET', '/desired/form/action.php', new Alert());
```

2). Define your form elements, and add them to your form. This assumes you've bound your form to the `$form` variable.

```
$ageElement = new TextInput('age');
$ageElement->setValidators([new Integer()]);
$form->addElement($ageElement);

$nameElement = new TextInput('name');
$nameElement->setValidators([new Alphanumeric()]);
$nameElement->setAttributes(['class' => 'form-control', 'id' =>'the-name-field']);
$nameElement->setHtmlBefore('');
$nameElement->setHtmlAfter('Some text');
$form->addElement($nameElement);

$submitElement = new Submit('submit');
$form->addElement($submitElement);
```

#### Form Rendering

[](#form-rendering)

3). Inject the form-object into your view

```

		renderJavascript(); ?>

		renderHtml(); ?>

```

Extending
---------

[](#extending)

Extending QuantumForms allows you to use additional elements to your form.

#### Additional Elements

[](#additional-elements)

1). Add file with new FormElement name to the `/src/FormElements directory`, e.g. `src/FormElements/Example`

An example extention could look like this:

```
namespace QuantumForms\FormElements;

/**
 * Example FormElement
 */
class Example extends AbstractFormElement implements \Quantumforms\FormElementInterface
{
    /**
     * (non-PHPdoc)
     * @see \QuantumForms\FormElements\AbstractFormElement::render()
     */
    public function render()
    {
        $attributes = $this->getAttributesString();
    	return $this->htmlBefore.''.$this->htmlAfter;
    }
}
```

Make sure you add your element test in the tests directory, `/tests/FormElements/Example.php`.

If you would like to contribute your element back to the QuantumForms project, consider opening a pull request with your changes.

#### Add Javascript Method to be invoked on a form error

[](#add-javascript-method-to-be-invoked-on-a-form-error)

Add file with JsErrorNotifier name to the `/src/JsErrorNotifiers directory`, e.g. `src/JsErrorNotifiers/Example`

```
namespace QuantumForms\JsErrorNotifiers;

/**
 * Example JsErrorNotifier
 */
class Example implements \QuantumForms\JsErrorNotifierInterface
{
	public function getJsErrorNotifier()
	{
	    return 'function (elementName, validatorName){
    	       //do something
    	    }';
	}
}
```

Add a test for your JsErrorNotifier to `/tests/JsErrorNotifiers/Example.php`

#### Additional Validators

[](#additional-validators)

Add file with validator name to the `/src/Validators directory`, e.g. `src/Validators/Example`

```
namespace QuantumForms\Validators;

use QuantumForms\Validator;
use QuantumForms\ValidatorInterface;
/**
 * Example Validator
 */
class Example extends AbstractValidator implements ValidatorInterface
{

    /**
     * @return bool
     */
    public function validate($input)
    {
        $bool = some_validation($input);
        return $bool;
    }

    /**
     * @return string
     */
    public function getJavascriptValidator()
    {
        return 'function (input) {
                    bool = some_validation(input);
                    return bool;
                }';
    }

}
```

Add a test for your Validator to `/tests/Validators/Example.php`

Help &amp; Support
------------------

[](#help--support)

This project doesn't come with any specific support plan, but I absolutely love helping out where I can. If you encounter any trouble with it at all, please don't hesitate to let me know. Just [open an issue](https://github.com/FranzWegener/QuantumForms/issues) and I'll do what I can.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

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.

### Community

Maintainers

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

---

Top Contributors

[![FranzWegener](https://avatars.githubusercontent.com/u/2787455?v=4)](https://github.com/FranzWegener "FranzWegener (50 commits)")

### Embed Badge

![Health badge](/badges/franzwegener-quantumforms/health.svg)

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

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

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