clonefish class overview

The class


Clonefish itself is a class hierarchy. We'll mostly work with the main class, which is the clonefish class. To use clonefish, we have to:

  1. create an instance of this class, and
  2. define the form fields using the configuration array (the format of this array is described under "Input types" and "Validation types" in the menu).
  3. if values are received from a submitted form, we use the $form->validate() method
  4. display the output using the $form->getHTML() method

On the first glance, it might seem to be too much work for a simple form, but when you start using clonefish, you'll find it very handy and efficient for more complicated forms - and it's always the same few lines code as above, just with a different configuration array!

Beyond the basics there are additional features already proven in dozens of applications, like:

  • template engine support: $clonefish->getVars()
  • invalidation: $clonefish->invalidate(), $clonefish->addMessage()
  • accessing element objects: $clonefish->getElementByName(), $clonefish->getValue()

A simple example:



$config = Array(
'login' => Array(
'type'        => 'inputText',  // type of field
'displayname' => 'Your name:'// label
'help'        => 'Please enter your name!'
// help message to display for invalid input values
'validation'  => Array(
'type' => 'required' )
// don't accept empty inputs

$clonefish = new clonefish'loginform''test.php''POST' );
$clonefish->addElements$config$_POST );

if ( isset( 
$_POST['login'] ) && $clonefish->validate() ) {
// do some action here
$clonefish->getHTML() .


form validation for developers!

clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain forms
learn more
Bookmark and Share