the basics

Well, a code block is worth a thousand words! Let's see an all-in-one example:

$config = Array(
  'name' => Array(
    'type'        => 'inputText',    // type of field
    'displayname' => 'Your name:',   // label
    'validation'  => Array(
       Array( 'type' => 'required' ) // don't accept empty inputs
$clonefish = new clonefish( 'formname', 'test.php', 'POST' );
$clonefish->addElements( $config, $_POST );
if ( count( $_POST ) && $clonefish->validate() ) {
  // wow! successful validation!
  print_r( $clonefish->getElementValues( false ) );
    "<html><body>" . 
    $clonefish->getHTML() .

That's how a valid and accessible XHTML form including JS and PHP validation is done.

Ofcourse there's much more in Clonefish: it has support for static and dynamic form input elements. Values for dynamic elements are retrieved from data sources like database queries (SQL). There are lots of customizable validation types to cover all the scenarios we've ever met.

An overview of supported elements:

  • text, password, hidden, textarea - the well known HTML inputs
  • radio + radioDynamic (radioDynamic for radio items based on SQL database queries)
  • select + selectDynamic (supports tree format for hierarchical structures, such as a multilevel category structure in a webshop), multiple selects
  • selectfile (creates a select to choose files or directories from a given filesystem directory; supports recursive directory reading)
  • checkbox + checkboxDynamic - checkboxDynamic is a versatile element to select multiple values
  • selectdate - customizable date selector
  • intelligent file upload widget
  • supports FCKeditor as WYSIWYG editor (any other editor can be added)
  • mapMarker - define coordinates using Google Maps easily with auto suggestion
  • reCaptcha - help digitising books while fighting spam!
  • fieldset element to organize form elements
  • template element type to create special form layouts
  • text element for plain text or HTML chunks

affiliate program!

Do you run a PHP blog or related website? Join as an affiliate and earn money!
know more

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