root/trunk/examples/patExampleGen/sections_event.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  * Definitions for the examples on the patForms event handling
4  *
5  * $Id$
6  *
7  * @package        patForms
8  * @subpackage    Examples
9  * @author        Sebastian Mordziol <argh@php-tools.net>
10  */
11
12     $sections['Event'] = array(
13         'descr'        =>    'Events allow you to implement a ways of handling forms via callbacks
14                         instead of nested condition blocks. In short, you canget rid of any
15                         big switch/case and if/else blocks to process your forms.<p/>
16                         You may register methods or functions that will be called if the form
17                         has been submitted, is valid or contains errors.<p/>
18                         Event handlers are similar to plugins as they allow you to interact
19                         with the form while it is being processed.',
20         'basename'    =>    'example_event_',
21         'pages'        =>    array(
22             'onsubmit' => array(
23                 'title'    =>    'onSubmit',
24                 'descr'    =>    'This example shows how to use the onSubmit handler to interact with
25                             your form once it has been submitted - in this case, to cancel the
26                             submission of the form altogether.',
27                 'tabs'  =>  array(
28                     'hilights' => array(
29                         'title' => 'Relevant parts',
30                         'type'  => 'guide',
31                         'file'  => '$exampleId.php',
32                         'guide' => array(
33                             array(
34                                 'lines' => '50-53',
35                                 'text' => 'Flag that sets whether to cancel the event',
36                             ),
37                             array(
38                                 'lines' => '58-60',
39                                 'text' => 'Register the event handler',
40                             ),
41                             array(
42                                 'lines' => '62-83',
43                                 'text' => 'The event handling function',
44                             ),
45                         ),
46                     ),
47                     'annotation' => array(
48                         'title' => 'Notes',
49                         'type'  => 'text',
50                         'text'  => 'You will probably have noticed that the event is cancelled
51                                     twice - this happens because of the autoValidation feature,
52                                     which leads to a double check of the form\'s submitted state.
53                                     It is not a bug, although we may implement a better tracking
54                                     for this.',
55                     ),
56                 ),
57             ),
58             'onsuccess' => array(
59                 'title'    =>    'onSuccess',
60                 'descr'    =>    'This example shows how to use the onSuccess handler to build a
61                             generic function that stores validated data.',
62                 'tabs'  =>  array(
63                     'hilights' => array(
64                         'title' => 'Relevant parts',
65                         'type'  => 'guide',
66                         'file'  => '$exampleId.php',
67                         'guide' => array(
68                             array(
69                                 'lines' => '98-100',
70                                 'text' => 'Register the event handler',
71                             ),
72                             array(
73                                 'lines' => '102-122',
74                                 'text' => 'The event handling function',
75                             ),
76                         ),
77                     ),
78                 ),
79             ),
80             'onerror' => array(
81                 'title'    =>    'onError',
82                 'descr'    =>    'This example shows how to use the onSuccess handler to build a
83                             generic function that displays error messages.',
84                 'tabs'  =>  array(
85                     'hilights' => array(
86                         'title' => 'Relevant parts',
87                         'type'  => 'guide',
88                         'file'  => '$exampleId.php',
89                         'guide' => array(
90                             array(
91                                 'lines' => '53-55',
92                                 'text' => 'Register the event handler',
93                             ),
94                             array(
95                                 'lines' => '57-84',
96                                 'text' => 'The event handling function',
97                             ),
98                         ),
99                     ),
100                 ),
101             ),
102             'combined' => array(
103                 'title'    =>    'Combining several event handlers',
104                 'descr'    =>    'This example shows you how to use several handlers in one script
105                             to automate form processing completely by using the autoValidate option.'
106             ),
107             'object' => array(
108                 'title'    =>    'Using an object as event handler',
109                 'descr'    =>    'This example shows you how to register an object that provides method
110                             for all events. This makes event handling even easier, as you have all
111                             event handling methods in one place.',
112                 'tabs'  =>  array(
113                     'hilights' => array(
114                         'title' => 'Relevant parts',
115                         'type'  => 'guide',
116                         'file'  => '$exampleId.php',
117                         'guide' => array(
118                             array(
119                                 'lines' => '53-106',
120                                 'text' => 'The event handling class',
121                             ),
122                             array(
123                                 'lines' => '108-109',
124                                 'text' => 'Instantiating the event handler object',
125                             ),
126                             array(
127                                 'lines' => '111-112',
128                                 'text' => 'Registering the event handler object',
129                             ),
130                         ),
131                     ),
132                 ),
133             ),
134         )
135     );
136 ?>
Note: See TracBrowser for help on using the browser.