FORM.CLASS.PHP

NAME

form.class.php

SYNOPSIS

form.class.php - a simple OO web form class for php

DESCRIPTION

form.class.php provides form text boxes, text areas, selects, checkboxes, hidden fields, and buttons

It is object orientated (OO) in that you create a form handle then add the required form elements (fields, buttons, etc) and form validation rules to that form handle

Form fields can be regex validated with feedback via a javascript message box

APPLICATION

 class Form
 Create, display, validate, process html forms
 No external dependencies
 
     Constructor for this form
     fh = new Form(name,[action = ''],[method = POST],[target = _self])
     name must be globally unique, eg f1
    
     Displays the form start html for this form
     null = fh->showFormStart( )
    
     Generates the form start html for this form
     string = fh->htmlStart()
    
     Displays the form end html for this form
     null = fh->showFormEnd( )
    
     Generates the form end html for this form (includes valiadtion js)
     string = fh->htmlEnd()
    
     Adds a validation rule (regex) to the named form element
     null or DIE = fh->addFormRule(name,regex,message)
    
     Adds a named form element to this form
     null or DIE = fh->addFormElement(name,type,attributes())
     type = TEXT(input),SUBMIT,HIDDEN,TEXTAREA,SELECT,PASSWORD,FILE,CHECKBOX
     name must be globally unique
     name by convention = formname_elementname
    
     eg TEXT arttributes = array ('size' => 10, 'extras' => 'stuff');
     eg SUBMIT attributes = array ('value' => 'HITME');
     eg HIDDEN attributes = array('value' => 'add'));
     eg TEXTAREA attributes = array ('rows' => '5', cols => '10');
     eg SELECT attributes = array ('options' => array( 'one' => '1-one', 'two' => '2-two'), 
     'extras' => 'stuff','selected' => 'two');
     eg CHECKBOX attributes = array ('checked' => 'true');
    
     Display html for this named form element
     null = fh->showFormElement('fred')
    
     Generate html for this named form element
     string or DIE = fh->getFormElement(name)

BUGS

None known

AUTHOR

John Bartlett
johnb@thesolution.com.au

SEE ALSO

Standalone