* @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. $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 string renderer $renderer =& patForms::createRenderer( "String" ); // the attributes we would like to have replaced in the form // template. Note that the rendrerer automatically replaces the // attributes title and label by default. $attributes = array( 'description', 'id', ); // set the attributes we want to have replaced in addition // to the default ones. $renderer->setAttributes( $attributes ); // set the template file to use $renderer->setTemplateFile( 'templates/example_renderer_string_attributes.html' ); // set the renderer $form->setRenderer( $renderer ); // use auto-validation $form->setAutoValidate( 'save' ); $content = $form->renderForm(); // ERROR DISPLAY ------------------------------------------------------ // ask the form if it has been submitted and display errors. For // convenience and also to keep the examples easy to understand, all // the following examples will use teh helper methods of the examples // framework to display the errors and the form. if( $form->isSubmitted() ) { displayErrors( $form ); // see patExampleGen/customFunctions.php } // DISPLAY FORM ------------------------------------------------------ echo $content; // EXAMPLE END ------------------------------------------------------ $exampleGen->displayFooter(); ?>