clonefish class properties
properties
properties controlling behaviour
js
$clonefish->js = 1;If set to 1, clonefish will produce JavaScript validation code. Default value: 1.
jspath
$clonefish->jspath = 'clonefish/clonefish.js';Path to the JavaScript code used by the validation procedure. The path will be written in the src parameter of the script tag, for example:
<script src="clonefish/clonefish.js">,
so you have to use either a relative or an absolute URI here.
dbtype
$clonefish->dbtype = 'adodb';This property determines the database wrapper class to use. By default, clonefish provides the following wrappers:
- 'adodb' for AdoDB library
- 'peardb' for Pear DB library
- 'mysql' for the built-in PHP MySQL functions
properties controlling output/layout
outputmessages
$clonefish->outputmessages = 1;If set to 1, clonefish will display error messages above the form in an unordered list. Default value: 1.
erroricon
$clonefish->erroricon =
'<IMG SRC="images/erroricon.gif">';
A string displayed next to the form field names
(or whatever you would like to display).
errorstyle
$clonefish->errorstyle =
'style="background-color: #e95724; "';
A string used in the output for an invalid
input. You'll find its %errorstyle% placeholder
in the layout arrays.
layouts
The layouts property holds the template strings
used by the gethtml() method to generate the HTML code
for the form. You can choose the current layout using the
layout property.
There are two basic layouts: tabular and
rowbyrow. Feel free to set up new layouts - just create
a new array, and use its array key in the layout
property.
The tabular layout:
| %displayname% | %erroricon% | %prefix%%element%%postfix% |
| %button% | ||
(
the table comes from $layouts['tabular']['container'],
the two rows are $layouts['tabular']['element'] and $layouts['tabular']['buttonrow'], see below!)
Example of a valid and an invalid row (a 'postfix' setting is used for the first element):
| (international format) | ||
![]() |
||
The rowbyrow layout:
%displayname% %erroricon%
%prefix%%element%%postfix%
%button%
%prefix%%element%%postfix%
%button%
Example of a valid and an invalid row (a 'postfix' setting is used for the first element):
(international format)

$clonefish->layouts = Array(
'tabular' => Array(
// the default tabular layout is a 3-column layout,
// 1st column: element displaynames,
// 2nd column: error icon if validation failed on the PHP side
// 3rd column: elements
'container' =>
'<table cellpadding="5" cellspacing="0" border="0">'.
"%s". // %s is a placeholder for the table body
'</table>n',
'element' =>
'<tr %errorstyle%>'.
'<td width="120" align="right">'.
' <label for="%id%">%displayname%</label>'.
'</td>'.
'<td width="15">%erroricon%</td>'.
'<td>%prefix%%element%%postfix%</td>'.
'</tr>',
// placeholders used:
// %id%: field id used with <label> to create
// accessible forms. (%id% defaults to the field name,
// and may be configured for any element)
// %displayname%, %prefix%, %postfix%: element settings
// %element%: generated HTML chunk of an element
// %errorstyle%: placeholder for the form errorstyle property.
// used only if a field is invalid
'buttonrow' =>
'<tr><td colspan=2></td><td>%s</td></tr>',
// %s : placeholder for the submit button defined in 'button'
'button' => '<input type=submit value="OK" />',
),
'rowbyrow' => Array(
'container' => '%s', // %s: see above
'element' =>
"<label for="%id%">%displayname%</label> %erroricon%<br>n".
"%prefix%%element%%postfix%n".
"<br><br>n",
// placeholders: see above
'buttonrow' => '%s', // %s: see above
'button' => '<input type=submit value="OK" />',
);
layout
$clonefish->layout = 'tabular';The
$layouts array contains arrays of layout strings.
These layout strings make flexible templating possible. The currently
used layout array is set using the $layout property
(use an index of $layouts).
layoutcleanup
$clonefish->layoutcleanup = true;If you use label tags in layout templates to create accessible forms, empty label tag pairs might be created when there's no displayname specified for an element (for obvious reasons:
<label for="%id%">%displayname%</label>).
If this property is set to true, such empty tag pairs are removed.
By default, it's set to true.
prefix, postfix
$clonefish->prefix = ''; $clonefish->postfix = '';Form prefix/postfix. Useful if you'd like to display some form information (eg. instructions, etc.) above or below the form. Contents will be place right before the <form> and after the </form> tags.
messageprefix, messagecontainerlayout, messagelayout, messagepostfix
$clonefish->messageprefix = FORM_ERRORS; // shown above error messages // FORM_ERRORS are defined in messages_XX.php $clonefish->messagecontainerlayout = '<ul>%s</ul>'; // %s: placeholder for 'messagelayout' rows $clonefish->messagelayout = '<li>%s</li>'; $clonefish->messagepostfix = ''; // shown below error messagesThese settings are used to customize the error message output. By default, error messages are displayed in an unordered list (error messages are displayed when the validation failed on the PHP side).
