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