* @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. Note that for each // the id attribute is set - the placeholders in the template // for the string renderer do not use an element's name, as // some elements have several subelements with the same name, // e.g. radio groups. $elementsDefinition = array( 'username' => array( 'type' => 'String', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'id' => 'user', 'label' => 'Username', 'title' => 'Username', 'description' => 'Please enter your username here.', ), ), 'password' => array( 'type' => 'String', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'id' => 'pass', 'type' => 'password', 'label' => 'Password', 'title' => 'Password', 'description' => 'Please enter your password here.', ), ), ); // create the form $form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) ); // create the needed renderer - in this case we use the string renderer // which gives you more control over the layout by inserting the rendered // elements directly in your output (HTML, text, etc.) via placeholders. $renderer =& patForms::createRenderer( "String" ); // the simple renderer needs to be configured - the most // important thing is to set the template from which to render the // form. It can come from anywhere, but has to be ASCII. $renderer->setTemplateFile( 'templates/example_renderer_string_errors.html' ); // you can also set the string to use directly: // $renderer->setTemplate( $string ); // set the renderer $form->setRenderer( $renderer ); // use auto-validation $form->setAutoValidate( 'save' ); $content = $form->renderForm(array(PATFORMS_RENDERER_STRING_RENDER_ERRORS => true)); // DISPLAY FORM ------------------------------------------------------ echo $content; // EXAMPLE END ------------------------------------------------------ $exampleGen->displayFooter(); ?>