| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
include_once 'patExampleGen/prepend.php'; |
|---|
| 19 |
$exampleGen->displayHead( 'Example' ); |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
require_once $neededFiles['patForms']; |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
require_once $neededFiles['patErrorManager']; |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
$elementsDefinition = array( |
|---|
| 40 |
'username' => array( |
|---|
| 41 |
'type' => 'String', |
|---|
| 42 |
'attributes' => array( |
|---|
| 43 |
'required' => 'yes', |
|---|
| 44 |
'display' => 'yes', |
|---|
| 45 |
'edit' => 'yes', |
|---|
| 46 |
'label' => 'Username', |
|---|
| 47 |
'description' => 'Enter your username here. Maximum length: [ELEMENT_MAXLENGTH]', |
|---|
| 48 |
'default' => 'argh', |
|---|
| 49 |
'maxlength' => '15', |
|---|
| 50 |
'minlength' => '4', |
|---|
| 51 |
'title' => 'Username', |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
'password' => array( |
|---|
| 55 |
'type' => 'String', |
|---|
| 56 |
'attributes' => array( |
|---|
| 57 |
'type' => 'password', |
|---|
| 58 |
'required' => 'yes', |
|---|
| 59 |
'display' => 'yes', |
|---|
| 60 |
'edit' => 'yes', |
|---|
| 61 |
'label' => 'Password', |
|---|
| 62 |
'description' => 'Enter your password here. Maximum length: [ELEMENT_MAXLENGTH]', |
|---|
| 63 |
'maxlength' => '15', |
|---|
| 64 |
'minlength' => '4', |
|---|
| 65 |
'title' => 'Password', |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
$form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) ); |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
$radioAtts1 = array( |
|---|
| 79 |
'required' => 'yes', |
|---|
| 80 |
'display' => 'yes', |
|---|
| 81 |
'edit' => 'yes', |
|---|
| 82 |
'label' => 'Area 51', |
|---|
| 83 |
'title' => 'Area 51', |
|---|
| 84 |
'description' => 'Click to select the area "[ELEMENT_LABEL]".', |
|---|
| 85 |
'clicklabel' => 'yes', |
|---|
| 86 |
'value' => '51', |
|---|
| 87 |
|
|---|
| 88 |
$radioAtts2 = array( |
|---|
| 89 |
'required' => 'yes', |
|---|
| 90 |
'display' => 'yes', |
|---|
| 91 |
'edit' => 'yes', |
|---|
| 92 |
'label' => 'Area 52', |
|---|
| 93 |
'title' => 'Area 52', |
|---|
| 94 |
'description' => 'Click to select the area "[ELEMENT_LABEL]".', |
|---|
| 95 |
'clicklabel' => 'yes', |
|---|
| 96 |
'value' => '52', |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
$radio1 = &$form->createElement('area', 'Radio', $radioAtts1); |
|---|
| 101 |
$radio2 = &$form->createElement('area', 'Radio', $radioAtts2); |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
$form->addElement($radio1); |
|---|
| 105 |
$form->addElement($radio2); |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
$renderer =& patForms::createRenderer( "Array" ); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
$form->setValues( |
|---|
| 119 |
|
|---|
| 120 |
'username' => 'schst', |
|---|
| 121 |
'password' => 'secret', |
|---|
| 122 |
'area' => 52, |
|---|
| 123 |
'bogus' => 'Not an element of the form' |
|---|
| 124 |
), |
|---|
| 125 |
false |
|---|
| 126 |
); |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
$form->setRenderer( $renderer ); |
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
$elements = $form->renderForm(); |
|---|
| 136 |
|
|---|
| 137 |
$_POST['save'] ) ) |
|---|
| 138 |
|
|---|
| 139 |
$form->setSubmitted( true ); |
|---|
| 140 |
|
|---|
| 141 |
$form->validateForm(); |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
if( $form->isSubmitted() ) |
|---|
| 151 |
|
|---|
| 152 |
displayErrors( $form ); |
|---|
| 153 |
} |
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
displayForm( $form, $elements ); |
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
$exampleGen->displayFooter(); |
|---|
| 163 |
?> |
|---|
| 164 |
|
|---|