Create forms that render and validate with ease.

0.4.0 2014-12-15 13:32 UTC


Build Status Packagist Software License

Reform makes it easy to create forms in PHP. Create a form, add rows and validation, then call render(). Everything else is done automatically - checking for submissions, validating data, setting values, creating labels and error messages, handling CSRF...

For greater control, the form can be rendered row-by-row, or even in individual pieces. You can use only a few features without the rest getting in the way.


  • Many row types and validation rules. It is trivial to add custom types to match your requirements.
  • Different renderers to apply styles to the form (e.g. Bootstrap). Changing the renderer can be done with a single line of code.
  • Integration with Symfony HttpFoundation to automatically submit forms.
  • Security measures like honeypot fields, timers, and CSRF protection. Add the Blockade security library to have these exceptions handled automatically.
  • Events to customize how forms behave.


A simple form with a username and password field.

$form = new Reform\Form\Form('/login');

echo $form->render();

Now with some validation.

$form = new Reform\Form\Form('/login');
    ->addRule(new Rule\Required('Did you forget your name?'))
    ->addRule(new Rule\Regex('`[A-z.]+`'))
    ->addRule(new Rule\Required());

Submit the form automatically by using a Symfony Request object. If the correct HTTP method was used and all fields have passed the required validation, the form is considered valid.

Valid or not, after a submission the fields are populated with the submitted data.

$request = Request::createFromGlobals();

if ($form->isValid()) {
    //the form was submitted correctly - the correct http method was
    //used and all validation rules passed

    //perform the login and redirect
//the form was either not submitted or failed the validation. $form
//now has any submitted parameters bound to it, so all we need to do
//is render the form again. Any values and errors will be added

echo $form->render();

See docs/ for further documentation.


Install using composer:

    "require": {
        "glynnforrest/reform": "0.4.*"

Viewing the examples

composer install
cd examples/
bower install
php -S localhost:8000

Then visit localhost:8000 in your web browser.

These instructions assume you have composer, bower and PHP 5.4 installed.


MIT, see LICENSE for details.

Copyright 2014 Glynn Forrest