1. Go to this page and download the library: Download omerucel/form 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/ */
omerucel / form example snippets
namespace {
use OU\Form\Field;
use OU\Form\Message\DangerMessage;
use OU\Form\Message\SuccessMessage;
use Respect\Validation\Rules;
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$form = new RegistrationForm($request);
if ($form->validate()) {
// Complete form action
$form->setCompleted(true);
$form->addMessage(new SuccessMessage('User created.'));
} else {
$form->addMessage(new DangerMessage('Please try again.'));
}
class RegistrationForm extends OU\Form\Form
{
public $email;
public $password;
public function __construct(Request $request)
{
$this->email = new Field($request->get('email'));
$this->email->addRule(new Rules\Email(), new DangerMessage('Invalid email address.'));
$this->password = new Field($request->get('password'));
$this->password->addRule(new Rules\NotEmpty(), new DangerMessage('Password is empty.'));
$this->password->addRule(new Rules\Length(8), new DangerMessage('Password is too short.'));
}
}
}
namespace {
use OU\Form\Form;
use OU\Form\Field;
use OU\Form\Message\DangerMessage;
use OU\Form\Message\SuccessMessage;
use Respect\Validation\Rules;
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$form = new Form();
$form->email = new Field($request->get('email'));
$form->email->addRule(new Rules\Email(), new DangerMessage('Invalid email address.'));
$form->password = new Field($request->get('password'));
$form->password->addRule(new Rules\NotEmpty(), new DangerMessage('Password is empty.'));
$form->password->addRule(new Rules\Length(8), new DangerMessage('Password is too short.'));
if ($form->validate()) {
$form->setCompleted(true);
$form->addMessage(new SuccessMessage('User created.'));
} else {
$form->addMessage(new DangerMessage('Please try again.'));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.