addElements()

clonefish->addElements() - add configuration and values for the form elements.

Description

class clonefish {
  void addElements( array $elements [, array $values, $quotes_already_added ] )
}

The heart of clonefish: with this method you can pass your configuration array to clonefish, which is used to 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.

Parameters

$elements

Associative array of element configuration.

$values

Associative array of element values, like

Array( 'fieldname' => 'value' )

Mostly used with the $_GET or $_POST array when processing a submitted form, or database records when preparing a modification form. This is an optional parameter, but if it's set, the third parameter is also required.

$quotes_already_added

Used to enable/disable stripslashes() on the array items given in the second parameter. By concept 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.

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$_GETget_magic_quotes_gpc() );
  
$form->addElements$elements$_POSTget_magic_quotes_gpc() );
  
$form->addElements$elements$values);
  
$form->addElements$elementsmysql_fetch_row(), );
  
$form->addElements$elements$adodbresult->fields);
  
// note the third parameter for 
  // arrays that don't go through magic quoting!

?>


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