[pLog-svn] r3588 - plog/trunk/class/data/forms

oscar at devel.lifetype.net oscar at devel.lifetype.net
Fri Jun 16 18:50:20 GMT 2006


Author: oscar
Date: 2006-06-16 18:50:19 +0000 (Fri, 16 Jun 2006)
New Revision: 3588

Modified:
   plog/trunk/class/data/forms/formvalidator.class.php
Log:
added some extra code to provide debug information regarding validation whenver a validation error occurs (set FORM_VALIDATOR_DEBUG to true at the top of the class)


Modified: plog/trunk/class/data/forms/formvalidator.class.php
===================================================================
--- plog/trunk/class/data/forms/formvalidator.class.php	2006-06-16 17:46:10 UTC (rev 3587)
+++ plog/trunk/class/data/forms/formvalidator.class.php	2006-06-16 18:50:19 UTC (rev 3588)
@@ -7,6 +7,12 @@
 	 */
 	
 	/**
+	 * Set this to true if you want to get some debug information every time
+	 * a validation error occurs
+	 */
+	define( "FORM_VALIDATOR_DEBUG", false );
+	
+	/**
 	 * \ingroup Forms
 	 *
 	 * This the class used for form validation. It works helped by the Validator classes to perform data validation,
@@ -21,6 +27,7 @@
 		var $_formIsValidated;
 		var $_formHasRun;
 		var $_fieldErrorMessages;
+		var $_formDebug;
 			
 		/**
 		 * initializes the form validator
@@ -35,6 +42,8 @@
 			$this->_fieldValues = Array();
 			$this->_fieldErrorMessages = Array();
 			
+			$this->_formDebug = FORM_VALIDATOR_DEBUG;
+			
 			// the form hasn't been validated yet
 			$this->_formIsValidated = false;
 			
@@ -111,6 +120,10 @@
 			// but... has it validated?
 			$this->_formIsValidated = $finalValidationResult;
 			
+			// in case we have to display some debug information
+			if( !$finalValidationResult && $this->_formDebug )
+				$this->dump();
+			
 			return $finalValidationResult;
 		}
 		
@@ -228,5 +241,20 @@
 		{
 			return $this->_fieldErrorMessages["$fieldName"];
 		}
+		
+		/**
+		 * dumps the current status of the form, useful for debugging 
+		 * purposes when we know that a field is not validating correctly but there
+		 * is no error message displayed on the screen
+		 */
+		function dump()
+		{
+			print("<pre>");
+			foreach( $this->_fieldValidators as $field => $validationInfo ) {
+				print( "field = $field - validator class = ".get_class( $validationInfo["validator"] ).
+				       " - status = ".$this->_validationResults["$field"]."<br/>" );
+			}
+			print("</pre>");
+		}
 	}
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list