PHP code example of glynnforrest / reform

1. Go to this page and download the library: Download glynnforrest/reform library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

glynnforrest / reform example snippets


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

echo $form->render();

$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');

$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();
bash
composer install
cd examples/
bower install
php -S localhost:8000