* @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_group.ftmpl', 'example_parser_pattemplate_group.tmpl' ); // now let patTemplate read the template file the parser just // created so that all needed templates are available $tmpl->readTemplatesFromFile( "example_parser_pattemplate_group.tmpl" ); // use auto-validation $form->setAutoValidate( 'save1' ); $group = $form->getElement('realname'); // 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() ) { $errors = $form->getValidationErrors(); echo '
'; print_r($errors); echo ''; echo "Values using PATFORMS_VALUES_NESTED
'; print_r($values); echo ''; echo "Values using PATFORMS_VALUES_FLATTENED
'; print_r($values); echo ''; echo "Values using PATFORMS_VALUES_PREFIXED
'; print_r($values); echo ''; // display errors if form is not valid if (!empty($errors)) { $tmpl->setAttribute( 'formErrors', 'visibility', 'visible' ); } else { // just to show that the form has been submitted with success... $tmpl->setAttribute( 'formSuccess', 'visibility', 'visible' ); } } // and display the template :) $tmpl->displayParsedTemplate(); // EXAMPLE END ------------------------------------------------------ $exampleGen->displayFooter(); ?>