Location: PHPKode > scripts > PXAServer > pxaserver/libreria/if_use_php5/FormMaker.class.php
<?php
/*
 * Classe che realizza form html
 */
class FormMaker {

	private $formOpen;		//stringa del form di apertura
	private $formClose;		//stringa del form di chiusura
	private $formElem;		//array di elementi da inserire nel form

    function FormMaker() {
    //Costruttore della classe FormMaker, istanzia anche la classe MSGmanager per la gestion dei m€ssaggi di errore
      	$this->error= new MSGmanager;             //Istanzio la classe MSGmanager per gestire i messaggi di errore	
    }
    function Form($name, $action, $method='POST') {
    //crea un form
    	$this->formOpen= "<form name=\"$name\" action=\"$action\" method=\"$method\">\n";
    	$this->formClose="</form>\n";
    }
    function InputBox($name,$type='text',$value='',$size='20',$maxlength='20') {
    //crea un inputBox Text - Password - TextArea
       	$this->formElem[]="<input name=\"$name\" type=\"$type\" value=\"$value\" size=\"$size\" maxlength=\"$maxlength\"><br>";
    }
    function Hidden($name="",$value="") {
    //crea un campo hidden
    	   	$this->formElem[]="<input type=\"hidden\" name=\"$name\" value=\"$value\"><br>";
    }    
    function MakeForm() {
    //crea un form con tutti gli elementi presi dall'array formElem
        $form .=$this->formOpen;
        $form .="<table width=\"90%\">\n";
        foreach ($this->formElem as $element){
       		$form .="<tr><td>".$element."</td></tr>\n";
        }
        $form .="</table>\n";
        $form .=$this->formClose;
        
        return $form;
       	
    }
    function Label($value) {
    //crea un campo hidden
    	   	$this->formElem[]="<label>".$value."</label><br>";
    }
    function Button($name,$value) {
    //crea un campo hidden
       	$this->formElem[]="<input type=\"submit\" name=\"$name\" value=\"$value\"><br>";
    } 
    function scrollBox($name,$value) {
    //crea un campo scrollBox
    $select .="<select name=\"$name\">";
        foreach ($value as $chiave => $option){
       		$select .="<option value=\"$chiave\">$option</option>\n";
        } 
    $select .="</select>";   	  
    $this->formElem[]=$select."<br>";
    }   
    function radioGroup($name,$value) {
    //crea un campo radioGroup
	    foreach ($value as $chiave => $option){
	    	$radioGroup .="<label>";
	       	$radioGroup .="<input type=\"radio\" name=\"$name\" value=\"$chiave\">\n";
	        $radioGroup .=$option."</label>";
	        } 
	    $this->formElem[]=$radioGroup."<br>";
	}
    function File($name) {
    //crea un campo File
       	$this->formElem[]="<input type=\"file\" name=\"$name\"><br>";
    }	
    function Image($name) {
    //crea un campo File
       	$this->formElem[]="<input name=\"$name\" type=\"image\"><br>";
    }	
    function chekBox($element) {
    //crea una serie di checkbox nell'array viene passato 
    //"chk01" => array("nome","valore","label")
	foreach ($element as $elemento){
		list ($name,$value,$label)=$elemento;
			$checkBox ="<label><input type=\"checkbox\" name=\"$name\" value=\"$value\">$label</label>";			
			$this->formElem[]=$checkBox."<br>\n";
		}
 
	}	
}
?>
Return current item: PXAServer