* @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']; /** * patForms parser class */ require_once $neededFiles['patForms_Parser']; /** * patErrorManager class */ require_once $neededFiles['patErrorManager']; /** * localisation stuff */ require_once $neededFiles['patI18n_configure']; /** * patTemplate class */ require_once $neededFiles['patTemplate']; // we need patTemplate for this to work $tmpl =& new patTemplate(); $tmpl->setBasedir( 'templates' ); // use the template object patForms_Parser::setStaticProperty( 'tmpl', $tmpl ); // set needed options. Setting the placeholders is needed, // as the patTemplate renderer replaces those variables // with the serialized elements. patForms_Parser::setNamespace( 'patForms' ); patForms_Parser::setCacheDir( 'cache' ); patForms_Parser::setBaseDir( 'templates' ); patForms_Parser::setPlaceholder( 'ELEMENT_%s' ); patForms_Parser::setFormPlaceholders( 'FORM_%s_START', 'FORM_%s_END' ); // tell the parser to parse our form template and save the output // form template, and to use the patTemplateRenderer. $forms = &patForms_Parser::createFormFromTemplate( 'patTemplateRenderer', 'example_parser_pattemplate_2forms.ftmpl', 'example_parser_pattemplate_2forms.tmpl' ); // now let patTemplate read the template file the parser just // created so that all needed templates are available $tmpl->readTemplatesFromFile( "example_parser_pattemplate_2forms.tmpl" ); $loginForm = &$forms->getForm('login'); $forgotForm = &$forms->getForm('forgot'); // use auto-validation $loginForm->setAutoValidate( 'save1' ); $forgotForm->setAutoValidate( 'save2' ); // render the content - the patTemplate renderer will then use the given template // names to render the elements and even the errors listing if there are any. $forms->renderForm( array( 'template' => 'form', 'errorTemplate' => 'formErrorsEntry' ) ); if( $loginForm->isSubmitted() ) { // display errors if form is not valid if( $loginForm->getValidationErrors() ) { $tmpl->setAttribute( 'formErrors', 'visibility', 'visible' ); } // just to show that the form has been submitted with success... else { $tmpl->setAttribute( 'formSuccess', 'visibility', 'visible' ); } } if( $forgotForm->isSubmitted() ) { // display errors if form is not valid if( $forgotForm->getValidationErrors() ) { $tmpl->setAttribute( 'formErrors', 'visibility', 'visible' ); } // just to show that the form has been submitted with success... else { $tmpl->setAttribute( 'formSuccess', 'visibility', 'visible' ); } } // and display the template :) $tmpl->displayParsedTemplate(); // EXAMPLE END ------------------------------------------------------ $exampleGen->displayFooter(); ?>