|
Revision 394, 2.8 kB
(checked in by gerd, 1 year ago)
|
Switched to patI18n
- removed all setLocale / getLocale functions from patForms, elements etc.
- use patI18n::dgettext with textdomain "patForms"
- added patI18n example
- added helper script to setup patI18n
- mended examples accordingly
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 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 |
require_once $neededFiles['patI18n_configure']; |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
$elementsDefinition = array( |
|---|
| 42 |
'username' => array( |
|---|
| 43 |
'type' => 'String', |
|---|
| 44 |
'attributes' => array( |
|---|
| 45 |
'required' => 'yes', |
|---|
| 46 |
'label' => 'Username', |
|---|
| 47 |
'description' => 'Enter your username here. Maximum length: [ELEMENT_MAXLENGTH]', |
|---|
| 48 |
'title' => 'Username', |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
'password' => array( |
|---|
| 52 |
'type' => 'String', |
|---|
| 53 |
'attributes' => array( |
|---|
| 54 |
'required' => 'yes', |
|---|
| 55 |
'label' => 'Password', |
|---|
| 56 |
'type' => 'password', |
|---|
| 57 |
'description' => 'Enter your password here. Maximum length: [ELEMENT_MAXLENGTH]', |
|---|
| 58 |
'title' => 'Password', |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
$defaultAttributes = array( |
|---|
| 65 |
'style' => 'width:100%', |
|---|
| 66 |
'maxlength' => '15', |
|---|
| 67 |
'minlength' => '4', |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
patForms::setDefaultAttributes( $defaultAttributes ); |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
$form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) ); |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
$form->setAutoValidate( 'save' ); |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
$renderer =& patForms::createRenderer( "Array" ); |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
$form->setRenderer( $renderer ); |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
$elements = $form->renderForm(); |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
if( $form->isSubmitted() ) |
|---|
| 99 |
|
|---|
| 100 |
displayErrors( $form ); |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
displayForm( $form, $elements ); |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
$exampleGen->displayFooter(); |
|---|
| 110 |
?> |
|---|
| 111 |
|
|---|