* @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']; // the DSN to your database $dsn = 'mysql://root:@localhost/pat'; // the table name $dbt = 'patForms_Storage'; // create the creator :) $creator = &patForms::createCreator( 'DB_Mysql' ); // create the form object from the given database $form =& $creator->create( $dsn, $dbt ); // create the needed renderer $renderer =& patForms::createRenderer( "Array" ); // set the renderer $form->setRenderer( $renderer ); // use auto-validation $form->setAutoValidate( 'save' ); // want to create and store in one go? Then combine the creator with // a storage object :) $storage =& patForms::createStorage( 'DB' ); // and set up... done! $storage->setStorageLocation( $dsn, $dbt ); $storage->setPrimaryField( 'user' ); $form->setStorage( $storage ); // 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(); ?>