Location: PHPKode > projects > PHP SiteBuilder > include/class.form.php
<?php
/**
 *	Form class to encapsulate form-fields
 *	
 *	@file	class.form.php
 *	@author	Tobias H. Michaelsen <thm-hide@address.com>
 *
 *	$Id: class.form.php,v 1.9 2001/08/31 13:44:30 phps Exp $
 */

if (defined('__CLASS_FORM_PHP')) return;
	define('__CLASS_FORM_PHP', 1);


Class Form
{
	// {{{ properties
	
	/** ACTION attribute of <FORM> tag */
	var $action;
	/** METHOD attribute of <FORM> tag */
	var $method;
	/** NAME attribute of <FORM> tag */
	var $name;
	/** an array of entries for this form */
	var $fields;
	/** DB_storage object, if tied to one */
	var $storageObject;
	/** <FORM ENCODING=""> attribute value */
	var $encoding;
	/** TARGET attribute of <FORM> tag */
	var $target;
	
	// }}}

	// {{{ constructor
	
	function Form($action, $method = 'GET', $name = '', $target = '') {
		$this->action = $action;
		$this->method = $method;
		$this->name = $name;
		$this->fields = array();
		$this->encoding = '';
		$this->target = $target;
	}
	
	// }}}


	// {{{ Hidden field
	
	/**
	 *	@func	returnHidden($name, $val)
	 *	@date	2000-10-05
	 *	@auth	Jesper Rønn	(JROE)
	 *	@ver	1.0
	 *
	 *	@hist	ver 0.99-13	initial version
	 */
	function returnHidden ($name, $val='') {
		return '<input type="hidden" name="'.$name.'" value="'.$val.'">'; 
	}
	
	// }}}

	// {{{ Text field
	
	/**
	 *	@func	returnText($name, $val, [$size])
	 *	@date	2000-11-12
	 *	@auth	Jesper Rønn	(JROE)
	 *	@ver	1.0
	 *	@hist	2000-11-12	initial version
	 */
	function returnText ($name, $value='', $size=25) {
		$str = ucfirst($name)." \t\t".'<input type="text" name="'.$name.'" size="'.$size.'"';
		if ($value != '')
			$str .= ' value="'.$value;
		return $str.'">';
	}
	// }}}

	// {{{ Submit button

	/**
	 *	@func	returnSubmit($name, $val, [$onClick])
	 *	@date	2000-11-12
	 *	@auth	Jesper Rønn	(JROE)
	 *	@ver	1.0
	 */
	function returnSubmit($name, $value, $onClick='') {
		$str =  '<input type="submit';
		if ($name != '')
			$str .= '" name="'.$name;
		$str .= '" value="'.$value;
		if ($onClick !='')
			$str .= '" onClick="'.$onClick;
		return $str.'">';
	}
	// }}}


} // end class Form

?>
Return current item: PHP SiteBuilder