displayHead( 'Example' ); require_once 'patForms.php'; require_once 'patErrorManager.php'; // element definitions for this example $elementsDefinition = array( 'username' => array( 'type' => 'String', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Username', 'title' => 'Username', 'description' => 'Please enter your username here.', ), ), 'passwd' => array( 'type' => 'String', 'attributes' => array( 'required' => 'no', 'type' => 'password', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Password', 'title' => 'Password', 'description' => 'Please enter your password here.', ), ), 'secret' => array( 'type' => 'String', 'attributes' => array( 'required' => 'no', 'type' => 'password', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Secret', 'title' => 'Secret', 'description' => 'Please enter your secret here.', // This forces the password to be sent to the browser when displaying the form // CAUTION: This may pose a security-risk as the password can be read in the // HTML-code. 'resendpasswd' => 'yes' ), ), ); // create the form $form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) ); $form->setNamespace('mynamespace'); // create the needed renderer $renderer =& patForms::createRenderer( "Array" ); // set the renderer $form->setRenderer( $renderer ); // use auto-validation $form->setAutoValidate( 'save' ); // serialize the elements $elements = $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 ------------------------------------------------------ displayForm( $form, $elements ); // see patExampleGen/customFunctions.php // EXAMPLE END ------------------------------------------------------ $exampleGen->displayFooter(); echo '
' . wordwrap(htmlentities(print_r($form->getElement('username')->serialize(), true)), 200);
?>