Public Member Functions | |
zRom_form ($method=null) | |
__construct ($method=null) | |
Sets the Form Method First argument should be either get or post in any case if no arguments are given it would try to detect the form method. | |
initValidator ($map_file) | |
Initilizes the validation System. | |
valueOf ($fieldName, $strict=false) | |
Returns the value of a Form Field Name. | |
isSubmitted () | |
Checks wheather or not form has been submitted. | |
Data Fields | |
$items = array() | |
$isValid = true | |
$is_submited = false | |
$frm_method |
$request->get
or $request->post
both are actually an Instance of zRom_form Class. This class works like a Container or all Get or post Field(s). actually There is a composition relation between zRom_fields and zRom_form cause all fields are contained into zRom_form as a zRom_fields object
Definition at line 162 of file map.php.
zRom_form::__construct | ( | $ | method = null |
) |
Sets the Form Method First argument should be either get or post in any case if no arguments are given it would try to detect the form method.
$method | string |
Reimplemented from validation.
Definition at line 184 of file map.php.
References validation::$method, and perror().
00184 { 00185 parent::__construct($method); 00186 //{ Make the $items array 00187 switch($method){ 00188 case 'GET': 00189 if(count($_GET) >= 1){ 00190 $this->items = $_GET; 00191 $this->is_submited = true; 00192 }else{ 00193 $this->is_submited = false; 00194 } 00195 $this->frm_method = '_GET'; 00196 break; 00197 case 'POST': 00198 if(count($_POST) >= 1){ 00199 $this->items = $_POST; 00200 $this->is_submited = true; 00201 }else{ 00202 $this->is_submited = false; 00203 } 00204 $this->frm_method = '_POST'; 00205 break; 00206 default: 00207 perror('Invalid method name supplied'); 00208 } 00209 //} 00210 }
zRom_form::zRom_form | ( | $ | method = null |
) |
Definition at line 181 of file map.php.
References validation::$method, and zCore::__construct().
00181 { 00182 $this->__construct($method); 00183 }
zRom_form::initValidator | ( | $ | map_file | ) |
Initilizes the validation System.
Validates the form by the provided Validation Map Name.
$map_file | string Name of the Validation Map e.g. if the map Name is abcd.vld.map.php just specify ancd here |
Definition at line 217 of file map.php.
References validationCore::$rules, zLogger::debug(), validationCore::errtext(), validationCore::isValid(), validationCore::parseCriteria(), and validationCore::validationStatus().
00217 { 00218 //load_module('validation'); 00219 zLogger::debug("Initializing Validation(GET/POST) System reading ".$map_file, 'rom.validation'); 00220 $this->isValid = false; 00221 $this->parseCriteria($map_file); 00222 $this->isValid = $this->isValid(); 00223 foreach($this->rules as $field_name => $rules){ 00224 $field_name = str_replace(' ', '_', $field_name);//Replace all SPACE with _ 00225 $errText = $this->errtext($field_name); 00226 $this->{$field_name} = &new zRom_fields($this->items[$field_name], $errText, $this->isValid($field_name), $this->validationStatus($field_name)); 00227 $validString = ($this->isValid($field_name)) ? "Valid" : "InValid"; 00228 zLogger::debug("Storing Form Field: $field_name Value:$field_name as $validString ErrText: ".$errText, 'rom.Validation'); 00229 //} 00230 } 00231 }
zRom_form::valueOf | ( | $ | fieldName, | |
$ | strict = false | |||
) |
Returns the value of a Form Field Name.
You can access get request parameters using $_GET/$_POST. However items/$_GET/$_POST is an associative array. If your error level is E_NOTICE PHP will fire Notice if you try to use items['someNonExistingField'] It will say index doesn't exist or similar Notice message. valueOf('fieldName') will also return value of that form field But if the form field doesn't exists it returns "" e.g. an empty string or false(if $strict is set to true) So PHP will not fire any Error message.
$fieldName | string Name of teh form Field thats value you want to retrive | |
$strict | boolean if set to true returns boolean false if the form field doesn't exists |
Definition at line 245 of file map.php.
00245 { 00246 return isset($this->items[$fieldName]) ? $this->items[$fieldName] : ($strict ? false : ""); 00247 }
zRom_form::isSubmitted | ( | ) |