about
Ever wondered how many HTML forms you created so far? Tens? Hundreds? Or even more? Do you still prefer reiterating the same snippets of HTML, the same chunks of PHP, or even pieces of JavaScript for the validation of the form? How many points of your site do you have to alter for a simple change in concept? Countless hours of coding, copy-pasting and modifying old validation code, testing to see whether it works, debugging if it doesn't... Far too many time spent for the same result every time!
If these problems sound familiar, you're not alone: we also wanted to get rid of the same old process of creating and evaluating forms manually. Despite our in-depth knowledge in HTML, we wanted something, that is much more flexible than an average HTML-based form class - something that has such an ease of use that it allows us to concentrate on actual application logic instead of tinkering with forms.
The clonefish development was a lengthy process, but by now, clonefish has matured and is a proven PHP class, aimed to aid the creation of input forms while supporting client- and server-side input validation, to allow the production of secure applications and websites.
key features
- Easy configuration using a flexible PHP array (see reference and examples!)
- Client-side form validation (with cross-browser JavaScript) and server-side form validation (with PHP)
- Automatic form generation with customizable layouts
- Static and dynamic form input elements. Values for dynamic elements are retrieved from database queries, offering some very handy special element types (FCKEditor support, file selector and much more!)
- Valid XHTML output
- Templating support by exporting the form elements to an array
- Multilanguage support for outputting error messages or other information - entirely Unicode compatible
- Supports array-fields:
<input type="checkbox" name="cb[0]">
or multiple selects like
<select name="multiselect[]" multiple="multiple">[...]</select> - for dynamic inputs virtually all databases are supported through the built-in AdoDB, Pear DB, native MySQL connectors - and you can still create your own connectors to any database!
- Optimized for faster loading times
supported form input types
Clonefish has support both for static and dynamic form input elements. Values for dynamic elements are retrieved from database queries. Supported elements:
- text, password, hidden, textarea, checkbox
- radio + radioDynamic
- select + selectDynamic (also available in tree format for hierarchical structures, such as a multilevel category structure in a webshop)
- selectfile (creates a select to choose files or directories from a given filesystem directory; supports recursive directory reading)
- multiple selects are supported for both select and selectDynamic
- intelligent file upload widget
- supports FCKeditor as WYSIWYG editor
- template element type to create special form layouts
validating a form has never been easier!
Client-side form validation (with cross-browser JavaScript) and server-side form validation with PHP. Supported validation types:
- Required validation:
- text, hidden, password, textarea: length of the input field value must be non-zero without the trailing and leading whitespaces
- checkbox: requires a checkbox to be checked
- radiobuttons or a multiple select: requires at least one option to be selected
- string validation: minimum/maximum length, regular expression matching
- number validation: minimum/maximum values, integer or real numbers
- date validation: date must match a specified date format, such as YYYY-MM-DD, MM/DD/YYYY, DD-MM-YYYY, hh:mm:ss, hh:mm, YYYY-MM-DD hh:mm:ss
- file validation: file type (one or more from JPG, GIF, PNG, SWF, BMP), file size (minimum/maximum), file upload required
- database validation: validation of input against a database query (the query is allowed to include any of the form's input values). The results of the query might be checked for exact value match, number of rows (minimum/maximum).
still undecided?
You may find other classes and solutions for form generation and validation, but apart from their feature-sets, clonefish also offers the following advantages:
- a mature, proven, flexible method for building forms and save your time
- used in hundreds of web sites and applications
- no need to create the forms in a HTML editor, though you can still use advanced styles
- easy to extend with new element types, new validation types
- flexibility that allows to keep your application code clean and easy to manage
- small memory footprint
