Location: PHPKode > projects > Webgolin > webgolin/core/connector/FormData.php
<?
/*************************************************************
*                        FormData.php                        *
*                 Copyright Softlech Corporation             *
*                  Created by: Fernando Martinez             *
*                        Jan 16, 2006                        *
**************************************************************/

/**
 * Represents data to fill a form before displaying it to the user.
 * It can be used to display loaded data from a db table, after an user
 * request, or to re-display user-entered data in a form, if required by 
 * an use-case. Example: if there was a failure processing the 
 * submitted form. 
 */
class FormData
{
	var $data = array();
	
	function FormData($data = null)
	{
		if(isset($data))
		{
			$this->data = $data;
		}
	}
	
	/** if the field exists, return the value, otherwise return 
	 * empty string (so, it can be safely used to initialise a new form)*/
	function getField($fieldName)
	{
		if(isset($this->data[$fieldName]))
		{
			return $this->data[$fieldName];
		}else
			return "";
	}
	
	/** used to modify or fill a specific field */
	function setField($fieldName,$value)
	{
		$this->data[$fieldName] = $value;
	}
}
?>
Return current item: Webgolin