Changeset 396 for trunk/examples

Show
Ignore:
Timestamp:
09/27/07 20:01:56 (1 year ago)
Author:
axel
Message:

Changed the way to calcualte the strlen. If the mb_strlen function is available, this will be used to calcuatle the length.

Added minlength and maxlength in string element example.

Now the patForms_Element_String and patForms_Element_Text classes are using the new way to calcualte the string length.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/example_element_string.php

    r268 r396  
    22/** 
    33 * Example for the Date element 
    4  *  
     4 * 
    55 * $Id$ 
    66 * 
     
    1919    $exampleGen->displayHead( 'Example' ); 
    2020 
    21      
     21 
    2222    // EXAMPLE START ------------------------------------------------------ 
    2323 
     
    2626     */ 
    2727    require_once $neededFiles['patForms']; 
    28      
     28 
    2929    /** 
    3030     * patErrorManager class 
     
    3232    require_once $neededFiles['patErrorManager']; 
    3333 
    34      
     34 
    3535    // element definitions for this example 
    3636    $elementsDefinition = array( 
     
    4444                'title'         =>  'Username', 
    4545                'description'   =>  'Please enter your username here.', 
     46                'minlength'     =>  2, 
     47                'maxlength'     =>  10 
    4648            ), 
    4749        ), 
     
    9395                'description'   =>  'Please enter your secret here.', 
    9496                // This forces the password to be sent to the browser when displaying the form 
    95                 // CAUTION: This may pose a security-risk as the password can be read in the  
     97                // CAUTION: This may pose a security-risk as the password can be read in the 
    9698                // HTML-code. 
    9799                'resendpasswd'  =>  'yes' 
     
    99101        ), 
    100102    ); 
    101      
     103 
    102104    // create the form 
    103105    $form   =&  patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) ); 
    104      
     106 
    105107    // create the needed renderer 
    106108    $renderer   =&  patForms::createRenderer( "Array" ); 
    107      
     109 
    108110    // set the renderer 
    109111    $form->setRenderer( $renderer ); 
    110      
     112 
    111113    // use auto-validation 
    112114    $form->setAutoValidate( 'save' ); 
     
    114116    // serialize the elements 
    115117    $elements   =   $form->renderForm(); 
    116      
    117      
     118 
     119 
    118120    // ERROR DISPLAY ------------------------------------------------------ 
    119121    // ask the form if it has been submitted and display errors. For