2017 © Pedro Peláez
 

library reform

Create forms that render and validate with ease.

image

glynnforrest/reform

Create forms that render and validate with ease.

  • Wednesday, June 10, 2015
  • by glynnforrest
  • Repository
  • 2 Watchers
  • 1 Stars
  • 899 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Reform

Build Status Packagist Software License, (*1)

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..., (*2)

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., (*3)

Features

  • 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.

Quickstart

A simple form with a username and password field., (*4)

$form = new Reform\Form\Form('/login');
$form->text('username');
$form->password('password');
$form->submit('login');

echo $form->render();

Now with some validation., (*5)

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

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., (*6)

Valid or not, after a submission the fields are populated with the submitted data., (*7)

$request = Request::createFromGlobals();
$form->handle($request);

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

    //perform the login and redirect
    login_user();
    redirect_to_home_page();
}
//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
//automatically.

echo $form->render();

See docs/ for further documentation., (*8)

Installation

Install using composer:, (*9)

{
    "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., (*10)

These instructions assume you have composer, bower and PHP 5.4 installed., (*11)

License

MIT, see LICENSE for details., (*12)

Copyright 2014 Glynn Forrest, (*13)

The Versions

10/06 2015

dev-master

9999999-dev

Create forms that render and validate with ease.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Glynn Forrest

form validation csrf honeypot

15/12 2014

0.4.0

0.4.0.0

Create forms that render and validate with ease.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Glynn Forrest

form validation csrf honeypot

19/08 2014

0.3.1

0.3.1.0

Forms using HttpFoundation that render and validate with ease.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Glynn Forrest

22/04 2014

0.3.0

0.3.0.0

Forms using HttpFoundation that render and validate with ease.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Glynn Forrest

12/04 2014

0.2.0

0.2.0.0

Forms using HttpFoundation that render and validate with ease.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Glynn Forrest

12/04 2014

0.1.2

0.1.2.0

Forms using HttpFoundation that render and validate with ease.

  Sources   Download

MIT

The Requires

 

by Glynn Forrest

02/04 2014

0.1.1

0.1.1.0

Forms using HttpFoundation that render and validate with ease.

  Sources   Download

MIT

The Requires

 

by Glynn Forrest

02/04 2014

0.1

0.1.0.0

Forms using HttpFoundation that render and validate with ease.

  Sources   Download

MIT

The Requires

 

by Glynn Forrest