root/tags/RELEASE_0_9_0B1/examples/example_element_hidden.php

Revision 117, 2.2 kB (checked in by argh, 4 years ago)

Massive update of the examples collection; added the patExampleGen examples framework; commented all examples; reworked all the templates...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * Example for the Date element
4  *
5  * $Id$
6  *
7  * @access        public
8  * @package        patForms
9  * @subpackage    Examples
10  * @author        Sebastian Mordziol <argh@php-tools.net>
11  * @license        LGPL, see license.txt for details
12  * @link        http://www.php-tools.net
13  */
14
15     /**
16      * Main examples prepend file, needed *only* for the examples framework!
17      */
18     include_once 'patExampleGen/prepend.php';
19     $exampleGen->displayHead( 'Example' );
20
21     
22     // EXAMPLE START ------------------------------------------------------
23
24     /**
25      * main patForms class
26      */
27     require_once $neededFiles['patForms'];
28     
29     /**
30      * patErrorManager class
31      */
32     require_once $neededFiles['patErrorManager'];
33
34     
35     // element definitions for this example
36     $elementsDefinition = array(
37         'area' => array(
38             'type' => 'Hidden',
39             'attributes' => array(
40                 'default'    =>    'a01',
41                 'label'        =>    '<- here! you can\'t see it, it\'s hidden :)'
42             ),
43         ),
44         'username' => array(
45             'type' => 'String',
46             'attributes' => array(
47                 'required'        =>    'yes',
48                 'display'        =>    'yes',
49                 'edit'            =>    'yes',
50                 'label'            =>    'Username',
51                 'title'            =>    'Username',
52                 'description'    =>    'Please enter your username here.',
53             ),
54         ),
55     );
56     
57     // create the form
58     $form    =&    patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) );
59     
60     // create the needed renderer
61     $renderer    =&    patForms::createRenderer( "Array" );
62     
63     // set the renderer
64     $form->setRenderer( $renderer );
65     
66     // use auto-validation
67     $form->setAutoValidate( 'save' );
68
69     // serialize the elements
70     $elements    =    $form->renderForm();
71     
72     
73     // ERROR DISPLAY ------------------------------------------------------
74     // ask the form if it has been submitted and display errors. For
75     // convenience and also to keep the examples easy to understand, all
76     // the following examples will use teh helper methods of the examples
77     // framework to display the errors and the form.
78     if( $form->isSubmitted() )
79     {
80         displayErrors( $form ); // see patExampleGen/customFunctions.php
81     }
82
83     // DISPLAY FORM ------------------------------------------------------
84     displayForm( $form, $elements ); // see patExampleGen/customFunctions.php
85
86
87     
88     
89     // EXAMPLE END ------------------------------------------------------
90     $exampleGen->displayFooter();
91 ?>
Note: See TracBrowser for help on using the browser.