Welcome Guest, Not a member yet? Register   Sign In
Form_validation run() method
#2

Well, I guess it could go either way. It seems to me that one reason the run() method returns FALSE when there are no validation rules is that the method in fact hasn't validated anything. Comments in the code would seem to support my theory (or wild guess).

PHP Code:
public function run($group '')
{
    
// Do we even have any data to process?  Mm?
    
if (count($_POST) == 0)
    {
        return 
FALSE;
    }

    
// Does the _field_data array containing the validation rules exist?
    // If not, we look to see if they were assigned via a config file
    
if (count($this->_field_data) == 0)
    {
        
// No validation rules?  We're done...
        
if (count($this->_config_rules) == 0)
        {
            return 
FALSE;
        } 

If you have a form you wish to process without any validation rules, you can still use the alternate style of checking for submit and then taking the values from the $_POST array.

PHP Code:
if ($_SERVER['REQUEST_METHOD'] == 'POST'
{
 
   // form was submitted
 
   // process the data, if any
}
else
{
 
   // perhaps redisplay form

Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply


Messages In This Thread
Form_validation run() method - by richard.rhsr - 04-08-2015, 12:33 PM
RE: Form_validation run() method - by RobertSF - 04-08-2015, 05:08 PM
RE: Form_validation run() method - by alkarim - 04-22-2015, 08:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB