metanet/form-handler

Library for an easy handling of web based forms written in PHP.

This package's canonical repository appears to be gone and the package has been frozen as a result.

v1.2.8 2016-05-13 12:53 UTC

README

Latest Stable Version Build Status License Total Downloads PHP 7 ready

This is a library for handling web based forms written in PHP. It takes care about verifying and rendering form components.

Basic requirements of the formHandler library are:

  • easy to use - without a lot of knowledge depending on processing forms in PHP.
  • efficiency boost - the library should generalize things you have to redo for each and every form and field in it

See the wiki for more information about how to use the library.

Install it using composer:

{
	"require": {
		"metanet/form-handler": "1.2.*"
	}
}

or via CLI: composer require metanet/form-handler:1.2.*

Quick code example:

<?php

$myForm = new Form();
$myForm->setInputData($_GET + $_POST);

$myField = new InputField('my_field', 'My field');
$myField->addRule(new RequiredRule('Please insert a value for my field'));

$myForm->addComponent($myField);

if($myForm->isSent() === true)
	if($myForm->validate() === true) {
		echo 'Form sent to the server and validated successfully!';
	} else {
		echo 'There have been errors during validation. Please check the red marked fields below.';
	}
}

echo $myForm->render();

/* EOF */