* @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( 'user' => array( 'type' => 'String', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Username', 'title' => 'Username', 'description' => 'Please enter your username here.', ), ), 'email' => array( 'type' => 'String', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Email', 'title' => 'Email', 'description' => 'Please enter your email address here.', 'format' => 'email', ), ), 'pass' => array( 'type' => 'String', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Password', 'title' => 'Password (Max. [ELEMENT_MAXLENGTH] / Min. [ELEMENT_MINLENGTH] chars)', 'type' => 'password', 'maxlength' => '8', 'minlength' => '6', 'description' => 'Please enter your password here (Max. [ELEMENT_MAXLENGTH] / Min. [ELEMENT_MINLENGTH] chars).', ), ), ); // 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' ); // create the mail storage object $mail =& patForms::createStorage( 'Mail' ); // You can use any mail driver, that PEAR::Mail provides // See the PEAR manual for more information. /* $mail->setMailDriver('smtp', array( 'host' => 'myserver.de', 'auth' => true, 'username' => 'user', 'password' => 'pass' ) ); */ $mail->setRecipient('schst@php-tools.net'); $mail->setHeaders( array( 'From' => 'patForms ', 'Subject' => 'New user request' ) ); // tell the form to use the storage object we just created. // That's all you need to do, the storage will handle $form->setStorage($mail); // serialize the elements $elements = $form->renderForm(); // ERROR DISPLAY ------------------------------------------------------ if ($form->isSubmitted()) { displayErrors($form); // see patExampleGen/customFunctions.php } // DISPLAY FORM ------------------------------------------------------ displayForm($form, $elements); // see patExampleGen/customFunctions.php // EXAMPLE END ------------------------------------------------------ $exampleGen->displayFooter(); ?>