* @license LGPL, see license.txt for details
* @link http://www.php-tools.net
*/
/**
* Main examples prepend file, needed *only* for the examples framework!
*/
include_once 'patExampleGen/prepend.php';
$exampleGen->displayHead( 'Example' );
// EXAMPLE START ------------------------------------------------------
/**
* main patForms class
*/
require_once $neededFiles['patForms'];
/**
* patErrorManager class
*/
require_once $neededFiles['patErrorManager'];
/**
* localisation stuff
*/
require_once $neededFiles['patI18n_configure'];
// element definitions for this example
$elementsDefinition = array(
'life' => array(
'type' => 'Text',
'attributes' => array(
'required' => 'yes',
'display' => 'yes',
'edit' => 'yes',
'label' => 'Life description',
'title' => 'Life description',
'description' => 'A short (maximum [ELEMENT_MAXLENGTH] character) description of your life so far.',
'default' => 'Since I discovered patForms, a new life has begun for me.',
'maxlength' => '700',
'minlength' => '4',
'rows' => '5',
'cols' => '60',
'allowedtags' => '*', // allow all tags (*) or named tags (e.g. 'b,i,em')
'deniedtags' => 'foo,i,bar' // deny all tags (*) or named tags (e,g. 'script')
),
),
);
// create the form
$form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) );
// create the needed renderer
$renderer =& patForms::createRenderer( "Array" );
// set the renderer
$form->setRenderer( $renderer );
// use auto-validation
$form->setAutoValidate( 'save' );
// serialize the elements
$elements = $form->renderForm();
// ERROR DISPLAY ------------------------------------------------------
// ask the form if it has been submitted and display errors. For
// convenience and also to keep the examples easy to understand, all
// the following examples will use teh helper methods of the examples
// framework to display the errors and the form.
if( $form->isSubmitted() )
{
displayErrors( $form ); // see patExampleGen/customFunctions.php
}
// DISPLAY FORM ------------------------------------------------------
displayForm( $form, $elements ); // see patExampleGen/customFunctions.php
// EXAMPLE END ------------------------------------------------------
$exampleGen->displayFooter();
?>