addElements() method
<?php
function addElements(
$elements,
$values = Array(),
$magic_quotes_already_added = null
)
?>
This is the heart of clonefish: with this method you can pass your configuration array (the first parameter) to clonefish, with which the class will create the HTML code and the validation code fragments. To learn about the configuration array, visit the form input types and the form validation configuration pages.
The second parameter is also an array, containing
'fieldname' => 'value' pairs. The second parameter is not mandatory, but if you pass an array, you'll have to define the third parameter too.
The third parameter is used to enable/disable stripslashes() on the array items given in the second
parameter. The concept is, that in Clonefish there should be no magic slashed data:
if you're using the second parameter, you have to tell Clonefish whether the values passed are
'magically quoted', or not. If you'd like to read more on handling quotes, see the Features section!
Parameter examples:
<?php
$elements = Array(
'name' => Array(
'type' => 'inputText',
'displayname' => 'Please enter your name'
);
$values = Array(
'name' => 'James Bond'
);
// the $values array might be a $_GET or
// $_POST array, or a database query result
// (or some array built manually)
$form->addElements( $elements, $_GET, get_magic_quotes_gpc() );
$form->addElements( $elements, $_POST, get_magic_quotes_gpc() );
$form->addElements( $elements, $values, 0 );
$form->addElements( $elements, mysql_fetch_row(), 0 );
$form->addElements( $elements, $adodbresult->fields, 0 );
// note the third parameter for
// arrays that don't go through magic quoting!
?>
