Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Lasantha Samarakoon  >  HTML Form Generator  >  test.php  >  Download  
File: test.php
Role: Unit test script
Content type: text/plain
Description: testing script and the documentation
Class: HTML Form Generator
Compose and generate HTML forms programmatically
Author: By
Last change: improved
Date: 5 years ago
Size: 5,762 bytes
 

Contents

Class file image Download
<html>
<head>
<style type="text/css">
    /* to list one element under another */
    input, select, label {display: block;)
</style>
</head>
<body>
<?php
require_once 'htmlform.inc.php';
$form = new HTMLForm();
  
/*
 ******************************************** INSTRUCTIONS TO USE ************************************************************

 *    --------------------------------------------------------------------------------------------------------------------------
 *    Program            : HTML Form Field Generator, PHP Class Library
 *    Version            : 1.0.0
 *    Files            : htmlform.inc.php, htmlform_base.inc.php, htmlform_exc.inc.php
 *    Author            : Lasantha Samarakoon
 *    Date released    : Monday, September 21, 2009
 *    Email            : lasn1987@gmail.com
 *    Licence            : http://www.gnu.org/licenses/gpl.txt
 *    --------------------------------------------------------------------------------------------------------------------------
 *
 *    This program is a freeware, which falls under GNU Genral Public Licence.
 *    ---------------------------------------------------------------------------------------------------------------------------
 *    You can modify this program, without any permission from the author. But be kind enough to send the updated version to the
 *    author through the above mentioned Email address.
 *    ---------------------------------------------------------------------------------------------------------------------------
 *    Documentation:
 *            Please refer the test.php file for hints on the usage of this class library.
 *    ---------------------------------------------------------------------------------------------------------------------------
 *
 *    ************************************* PROUD TO BE A SRI LANKAN...!!! ******************************************************

 
NOTE: [x] indicates that x is optional.

HTMLForm:
    Constructor: ([string name], [string id], [string action], [string method], [string enctype], [string class])
    void addElement(object element, string element_name)
    void removeElement(string element_name)
    string generate();
    
    Properties:
        name, id, action, method, enctype, class
------------------------------------------------------------------------------------------------------------------------------
    
TextField, HiddenField, PasswordField:
    Constructor: ([string name], [string id], [string value], [string class], [bool disabled])
    string generate();
    
    Properties:
        name, id, value, class, disabled
------------------------------------------------------------------------------------------------------------------------------

Label:
    Constructor: ([string value], [string rel], [string id], [string class])
    string generate()
    Properties:
        value, rel, id, class
------------------------------------------------------------------------------------------------------------------------------

SelectBox:
    Constructor: ([string name], [string id], [string class], [bool disabled])
    void addOption(string key, string text, [string value], [bool selected])
    void removeOption(string key)
    string generate()
    
    Properties:
        name, id, class, disabled
------------------------------------------------------------------------------------------------------------------------------
    
Textarea:
    Constructor: ([string name], [string id], [string value], [string class], [bool disabled])
    string generate();
    
    Properties:
        name, id, value, class, disabled
------------------------------------------------------------------------------------------------------------------------------

CheckBox, Radio:
    Constructor: ([string name], [string id], [bool checked], [string class], [bool disabled])
    string generate();
    
    Properties:
        name, id, checked, class, disabled
------------------------------------------------------------------------------------------------------------------------------
        
SubmitButton, ResetButton, GeneralButton:
    Constructor: [string name],[string id], [string value], [string class], [bool disabled]
    string generate()
    
    Properties:
        name, id, value, class, disabled
------------------------------------------------------------------------------------------------------------------------------
 */

$form = new HTMLForm(nullnull"server_script.php""POST""multipart/form-data");

$form->addElement(new Label("Text field: ""txt"), "lbl_1");
$form->addElement(new TextField("txt"null"TextField"), "el_1");

$form->addElement(new Label("Hidden field: ""hdn"), "lbl_2");
$form->addElement(new TextField("hdn"null"HiddenField"), "el_2");

$form->addElement(new Label("Password field: ""pass"), "lbl_3");
$form->addElement(new TextField("pass"null"PasswordField"), "el_3");
    
$form->addElement(new Label("Select box: ""sb"), "lbl_4");
$sb = new SelectBox("sb");
    
$sb->addOption("1""Sri Lanka""lk");
    
$sb->addOption("2""India""in");
    
$sb->addOption("3""Australia""au");
    
$sb->addOption("4""United States of America""us");
    
$sb->addOption("5""Japan""jp");
$form->addElement($sb"el_4");

$form->addElement(new Label("Text area: ""txtarea"), "lbl_5");
$form->addElement(new Textarea("txtarea"null"Textarea"), "el_5");

$form->addElement(new Label("Check box: ""chbox"), "lbl_6");
$form->addElement(new CheckBox("chbox"nulltrue), "el_6");

$form->addElement(new Label("Radio button: ""rad"), "lbl_7");
$form->addElement(new Radio("rad"), "el_7");

$form->addElement(new SubmitButton("btnsub"null"Submit"), "el_8");
$form->addElement(new ResetButton("btnrst"null"Reset"), "el_9");
$form->addElement(new GeneralButton("btngen"null"General"), "el_10");

echo 
$form->generate();
 
?>
</body>
</html>