root/tags/RELEASE_0_9_0B1/examples/example_element_pool_multi.php

Revision 117, 4.1 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         'mammalians' => array(
38             'type' => 'Pool',
39             'attributes' => array(
40                 'label'            =>    'Mammalians',
41                 'title'            =>    'Mammalians',
42                 'description'    =>    'List of mammals',
43                 'size'            =>    '10',
44                 'style'            =>    'width:150px;',
45                 'class'            =>    'pool',
46                 'candidates'    =>    array(
47                     array(   
48                         'label'    =>    'Ant',
49                         'value'    =>    'ant',
50                      ),
51                     array(   
52                         'label'    =>    'Bee',
53                         'value'    =>    'bee',
54                      ),
55                     array(   
56                         'label'    =>    'Dog',
57                         'value'    =>    'deg',
58                      ),
59                     array(   
60                         'label'    =>    'Cat',
61                         'value'    =>    'cat',
62                      ),
63                     array(   
64                         'label'    =>    'Shark',
65                         'value'    =>    'shark',
66                      ),
67                     array(   
68                         'label'    =>    'Whale',
69                         'value'    =>    'whale',
70                      ),
71                 ),
72                 'candidatetitle'    =>    'Animals',
73                 'membertitle'        =>    'Mammalians',
74                 'titleclass'        =>    'pooltitle',
75                 'tooladd'            =>    'add mammalian',
76                 'toolremove'        =>    'remove animal',
77                 'toolclass'            =>    'pooltool',
78             ),
79         ),
80         'freaks' => array(
81             'type' => 'Pool',
82             'attributes' => array(
83                 'label'            =>    'Freaks',
84                 'title'            =>    'Freaks',
85                 'description'    =>    'List of freaks',
86                 'class'            =>    'pool',
87                 'style'            =>    'width:150px;',
88                 'candidates'    =>    array(
89                     array(   
90                         'label'    =>    'Sebastian Bergmann',
91                         'value'    =>    1001,
92                      ),
93                     array(   
94                         'label'    =>    'Alexander Wirtz',
95                         'value'    =>    1002,
96                      ),
97                     array(   
98                         'label'    =>    'Paul Hammant',
99                         'value'    =>    1003,
100                      ),
101                     array(   
102                         'label'    =>    'Björn Schotte',
103                         'value'    =>    1004,
104                      ),
105                     array(   
106                         'label'    =>    'Tobias Schlitt ',
107                         'value'    =>    2004,
108                      ),
109                     array(   
110                         'label'    =>    'George Schlossnagl',
111                         'value'    =>    3001,
112                      ),
113                     array(   
114                         'label'    =>    'Christian Wenz',
115                         'value'    =>    4001,
116                      ),
117                     array(   
118                         'label'    =>    'Marc Pohl',
119                         'value'    =>    5001,
120                      ),
121                     array(   
122                         'label'    =>    'Mark Britton',
123                         'value'    =>    5002,
124                      ),
125                     array(   
126                         'label'    =>    'Peter Petermann',
127                         'value'    =>    5003,
128                      ),
129                     array(   
130                         'label'    =>    'Wilko Miletic',
131                         'value'    =>    5004,
132                      ),
133                     array(   
134                         'label'    =>    'Tobias Hauser',
135                         'value'    =>    5005,
136                      ),
137                     array(   
138                         'label'    =>    'Geir Torstein Kristiansen',
139                         'value'    =>    5006,
140                      ),
141                     array(   
142                         'label'    =>    'Jan Kneschke',
143                         'value'    =>    5007,
144                      ),
145                 ),
146                 'candidatetitle'    =>    'people',
147                 'membertitle'        =>    'freaks',
148                 'titleclass'        =>    'pooltitle',
149             ),
150         ),
151     );
152     
153     // create the form
154     $form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) );
155     
156     // create the needed renderer
157     $renderer =& patForms::createRenderer( "Array" );
158     
159     // set the renderer
160     $form->setRenderer( $renderer );
161     
162     // use auto-validation
163     $form->setAutoValidate( 'save' );
164
165     // serialize the elements
166     $elements    =    $form->renderForm();
167     
168     
169     // ERROR DISPLAY ------------------------------------------------------
170     // ask the form if it has been submitted and display errors. For
171     // convenience and also to keep the examples easy to understand, all
172     // the following examples will use teh helper methods of the examples
173     // framework to display the errors and the form.
174     if( $form->isSubmitted() )
175     {
176         displayErrors( $form ); // see patExampleGen/customFunctions.php
177     }
178
179     // DISPLAY FORM ------------------------------------------------------
180     displayForm( $form, $elements ); // see patExampleGen/customFunctions.php
181
182
183     
184     
185     // EXAMPLE END ------------------------------------------------------
186     $exampleGen->displayFooter();
187 ?>
Note: See TracBrowser for help on using the browser.