PHPackages                             dimensi0n/simple-form - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dimensi0n/simple-form

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dimensi0n/simple-form
=====================

Simple Form generator

1.0.2(5y ago)112[1 PRs](https://github.com/dimensi0n/simple-form/pulls)MITPHP

Since Apr 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dimensi0n/simple-form)[ Packagist](https://packagist.org/packages/dimensi0n/simple-form)[ RSS](/packages/dimensi0n-simple-form/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (6)Used By (0)

simple-form
===========

[](#simple-form)

[![PHP Composer](https://github.com/dimensi0n/simple-form/workflows/PHP%20Composer/badge.svg)](https://github.com/dimensi0n/simple-form/workflows/PHP%20Composer/badge.svg)

Provides a simple form generator and a data validator

How to use it ?
---------------

[](#how-to-use-it-)

Install it :

```
composer require dimensi0n/simple-form

```

This :

```
$form = new \SimpleForm\Form('Login');
        $form->addInput('email', 'email', 'Email address') // name, type, label
		   ->addInput('password', 'password', 'Mot de passe') // name, type, label
           ->addSubmit('Submit'); // content

echo $form->renderHTML;
```

Will render this :

```

    Email Address

    Password

    Submit

```

In order to validate the form and get its value you just have to write this :

```
$values = $form->getValues($_POST); // check if all fields are filled, also applies trim(), stripslashes() and htmlspecialchars()

if (isset($values['empty'])) {
    foreach($values['empty'] as $empty_value) {
        echo $empty_value.' is empty'; // 'Name of the empty field' is empty
    }
} else {
    echo 'Email : '.$values['email'];
    echo 'Password : '.$values['password'];
}
```

Custom Rendering
----------------

[](#custom-rendering)

Example with bootstrap :

```
$form = new \SimpleForm\Form('Login');
        $form->addInput('email', 'email', 'Email address') // name, type, label
		   ->addInput('password', 'password', 'Mot de passe') // name, type, label
           ->addSubmit('Submit'); // content
