* @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" ); // you can set the placeholder to use for the elements and the element // attributes if you don't like the default ones, or by some wild // unexplainable reason use just the same placeholders in your application. $renderer->setPlaceholder( '{ARGH_ELEMENT_%s}' ); // you can also set the placeholders for the form's opening and closing // tags, for the same obvious reasons as above :) $renderer->setFormPlaceholders( '{ARGH_FORM_%s_START}', '{ARGH_FORM_%s_END}' ); // set the template file to use $renderer->setTemplateFile( 'templates/example_renderer_string_placeholders.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(); ?>