* @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. $form = &patForms_Parser::createFormFromTemplate( 'patTemplateRenderer', 'example_parser_pattemplate.ftmpl', 'example_parser_pattemplate.tmpl' ); // now let patTemplate read the template file the parser just // created so that all needed templates are available $tmpl->readTemplatesFromFile( "example_parser_pattemplate.tmpl" ); // use auto-validation $form->setAutoValidate( 'save' ); // 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. $form->renderForm( array( 'template' => 'form', 'errorTemplate' => 'formErrorsEntry' ) ); if( $form->isSubmitted() ) { // display errors if form is not valid if( $form->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(); ?>