root/tags/RELEASE_0_9_0B1/examples/example_element_radiogroup.php

Revision 117, 2.4 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         'username' => array(
38             'type' => 'RadioGroup',
39             'attributes' => array(
40                 'required'        =>    'yes',
41                 'display'        =>    'yes',
42                 'edit'            =>    'yes',
43                 'label'            =>    'Area',
44                 'title'            =>    'Area',
45                 'description'    =>    'Choose the area to access here.',
46                 'position'        =>    '3',
47                 'clicklabel'    =>    'yes',
48                 'default'        =>    'a03',
49                 'values'        =>    array(
50                     array(
51                         'label'    =>    'Very pretty area',
52                         'value'    =>    'a01',
53                     ),
54                     array(
55                         'label'    =>    'No-nonsense area',
56                         'value'    =>    'a02',
57                     ),
58                     array(
59                         'label'    =>    'Argh-area',
60                         'value'    =>    'a03',
61                     ),
62                 ),
63             ),
64         ),
65     );
66     
67     // create the form
68     $form    =&    patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) );
69     
70     // create the needed renderer
71     $renderer    =&    patForms::createRenderer( "Array" );
72     
73     // set the renderer
74     $form->setRenderer( $renderer );
75     
76     // use auto-validation
77     $form->setAutoValidate( 'save' );
78
79     // serialize the elements
80     $elements    =    $form->renderForm();
81     
82     
83     // ERROR DISPLAY ------------------------------------------------------
84     // ask the form if it has been submitted and display errors. For
85     // convenience and also to keep the examples easy to understand, all
86     // the following examples will use teh helper methods of the examples
87     // framework to display the errors and the form.
88     if( $form->isSubmitted() )
89     {
90         displayErrors( $form ); // see patExampleGen/customFunctions.php
91     }
92
93     // DISPLAY FORM ------------------------------------------------------
94     displayForm( $form, $elements ); // see patExampleGen/customFunctions.php
95
96
97     
98     
99     // EXAMPLE END ------------------------------------------------------
100     $exampleGen->displayFooter();
101 ?>
Note: See TracBrowser for help on using the browser.