Source
This is the config array for Clonefish
which generates the form you've just seen.
Scroll at the bottom of this window
to see how to use this array!
<?php
$info = 'This is a single fieldset setup: you can see the
fields in the fieldset and the legend. Since the fieldset is
meant to group the fields (and not the whole form),
you\'ll find the submit button
outside the fieldset - you can change this behaviour
by setting the "submit" configuration parameter to 1,
as you\'ll see in the two other fieldset example.';
$config = Array(
'fieldset' => Array(
'type' => 'fieldset',
'legend' => 'This is a fieldset legend',
),
'inputText' => Array(
'type' => 'inputText',
'displayname' => 'A plain text field',
),
'inputPassword' => Array(
'type' => 'inputPassword',
'displayname' => 'A password field',
),
'textarea' => Array(
'type' => 'textarea',
'html' => 'cols="20" rows="3"',
'displayname' => 'A textarea',
),
'inputHidden' => Array(
'type' => 'inputHidden',
'value' => "something you don't want the users to see",
),
);
?>
Usage example
To create a form using this array you'll only need
a few lines of code:
<?php
// create the form object
$clonefish = new clonefish( 'loginform', 'test.php', 'POST' );
// setup codepage so your data will be handled
// perfectly by the appropriate string functions
$clonefish->codepage = 'utf-8';
$clonefish->multibytesupport = 'multibyteutf8';
// add the form elements (fields) pre-filled with
// values from $_POST
$clonefish->addElements( $config, $_POST, get_magic_quotes_gpc() );
// validate the form if the form has been submitted
if ( count( $_POST ) && $clonefish->validate() ) {
// form is valid, go and store values in database, etc.
// $clonefish->getElementValues() provides a
// normalized value array.
}
else
// if the form wasn't submitted yet or the validation
// had failed, show the form (automatically
// including error messages)
echo
"<html><body>" .
$clonefish->getHTML() .
"</body></html>";
?>