Location: PHPKode > scripts > class.autoform.php > class-autoform-php/class.autoform.php
<?php
/**
*	Class Auto-Niceform
*	PHP class for using niceform.
*
*	@author Chetan <hide@address.com>
*	@version 1 9 June 2009
*	@copyright GPL © 2007, Chetan Mendhe
*	@license http://creativecommons.org/licenses/by-nc-sa/3.0/ Released under a Creative Commons License
*/
class niceform
{
	var $self;
	protected $base="http://6227534206115336217-a-1802744773732722657-s-sites.googlegroups.com/site/xtrmcoder/Home/";
	var $html;
	/**
	*	Niceform Construct
	*	@access public
	*	@param String $method Form method 
	*	@param String $action Action URL of form
	*	@return void
	*/
	public function niceform($method,$action)
	{
		$this->self[method]=$method;
		$this->self[action]=$action;
	}
	/**
	*	Embed HTML and CSS of Niceform in HEAD part of the html
	*	@access public
	* 	@return void
	*/
	public function head()
	{
		$css_=array();
		$js_=array();
		$css_['src']=$this->base."niceforms-default.css";
		$css_['type']="text/css";
		$css_['media']="all";
		$css_['html']="<link rel=\"stylesheet\" type=\"$css_[type]\" media=\"$css_[media]\" href=\"$css_[src]\" />";
		$js_['src']=$this->base."niceforms.txt";
		$js_['language']="javascript";
		$js_['type']="text/javascript";
		$js_['html']="<script language=\"$js_[language]\" type=\"$js_[type]\" src=\"$js_[src]\"></script>";
		echo $js_['html']."\n".$css_['html'];
	}
	/** 
	* Start
	* @access public
	* @param String $title Title of form
	* @return void
	*/
	public function start($title)
	{
		$this->html.="<div id=\"container\">\n";
		$this->html.="<form action=\"".$this->self['action']."\" method=\"".$this->self['method']."\" class=\"niceform\">\n";
		$this->html.="	<fieldset>\n";
		$this->html.="    	<legend>$title</legend>\n";
	}
	/**
	* @access public
	* @param String $title Title Name of the Field
	* @param String $type Type of the field
	* @param String $name Name of the field
	* @param String $id Id of the field
	* @param Array $attributes Additional Attributes you want to add in format . $array[attributeName]=Value;
	* @return void
	*/
	public function add_field($title,$type,$name="",$id="",$attributes="")
	{
		$this->html.="        <dl>\n";
		$this->html.="        	<dt><label>$title</label></dt>\n";
		$this->html.="  <dd><input type=\"$type\" name=\"$name\" id=\"$id\" size=\"32\"";
		if($attributes)
		{
			foreach($attributes as $name=>$value)
			{
				$this->html.=" $name=\"$value\"";
			}
			
		}
		$this->html.=" /></dd>\n    </dl>\n";
	}
	/**
	* Close the Form
	* @access public
	* @return void
	*/
	public function close()
	{
		$this->html.="   </fieldset>\n";
		$this->html.="</form>\n</div>\n";
	}
	/**
	* Get HTML code for the ready form
	* @access public
	* @return string
	*/
	public function getHTML()
	{
		return $this->html;
	}
}
?>
Return current item: class.autoform.php