displayHead( 'Example' ); require_once 'patForms.php'; require_once 'patErrorManager.php'; // element definitions for this example $elementsDefinition = array( 'testfile' => array( 'type' => 'File', 'attributes' => array( 'id' => 'testfile', 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'title' => 'File upload', 'label' => 'File upload', 'description' => 'Upload a file of your choice...', 'uploaddir' => './fileupload', 'overwrite' => 'no', 'usesession' => 'no', //'maxsize' => 20000, //'tempdir' => '/tmp' //'permissions' => 0666, //'replacename' => 'i/[^a-z0-9]\./_', //'mimetype' => array( 'image/*', 'image/png' ), ), ), 'teststring' => array( 'type' => 'String', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Test string', 'title' => 'Test string', 'description' => 'Enter some text here and test some validation errors. Min length: [ELEMENT_MINLENGTH], Max length: [ELEMENT_MAXLENGTH]', 'default' => 'x', 'maxlength' => '15', 'minlength' => '4', ), ), ); // create the form $form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm', 'enctype' => 'multipart/form-data' ) ); $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('testfile')->serialize(), true)), 200); ?>