root/tags/RELEASE_0_9_0B1/examples/example_element_radio.php

Revision 117, 2.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         'username' => array(
38             'type' => 'Radio',
39             'attributes' => array(
40                 'required'        =>    'yes',
41                 'display'        =>    'yes',
42                 'edit'            =>    'yes',
43                 'label'            =>    'Area 51',
44                 'title'            =>    'Area 51',
45                 'description'    =>    'Click to select the area &quot;[ELEMENT_LABEL]&quot;.',
46                 'clicklabel'    =>    'yes',
47                 'value'            =>    '51',
48             ),
49         ),
50     );
51     
52     // create the form
53     $form    =&    patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) );
54     
55     // create the needed renderer
56     $renderer    =&    patForms::createRenderer( "Array" );
57     
58     // set the renderer
59     $form->setRenderer( $renderer );
60     
61     // use auto-validation
62     $form->setAutoValidate( 'save' );
63
64     // serialize the elements
65     $elements    =    $form->renderForm();
66     
67     
68     // ERROR DISPLAY ------------------------------------------------------
69     // ask the form if it has been submitted and display errors. For
70     // convenience and also to keep the examples easy to understand, all
71     // the following examples will use teh helper methods of the examples
72     // framework to display the errors and the form.
73     if( $form->isSubmitted() )
74     {
75         displayErrors( $form ); // see patExampleGen/customFunctions.php
76     }
77
78     // DISPLAY FORM ------------------------------------------------------
79     displayForm( $form, $elements ); // see patExampleGen/customFunctions.php
80
81
82     
83     
84     // EXAMPLE END ------------------------------------------------------
85     $exampleGen->displayFooter();
86 ?>
Note: See TracBrowser for help on using the browser.