Page 1 of 1

I'm confused

PostPosted: Thu Jul 05, 2012 8:38 am
by clawes
I have form for a table named distribution_list using the PHP class below.
Whenever I try to add or update an existing record, Xataface takes me to an empty page.
The apache error_log file is showing the following error:
Code: Select all
[Thu Jul 05 11:15:01 2012] [error] [client 10.12.12.73] PHP Fatal error:  Call to undefined function hasWhiteSpace() in /var/www/html/contacts/tables/distribution_list/distribution_list.php on line 17, referer: http://file1.ykf.navtech.corp/contacts/index.php?-action=new&-table=distribution_list


This error seems to suggest that I am missing the hasWhiteSpace function. However this function is clearly defined in the ../tables/distribution_list/distribution_list.php function as shown in the code below.
What am I missing?

Code: Select all
<?php
class tables_distribution_list {

function beforeSave(&$record)
{
        $this_user = $_SESSION['UserName'];
        $record->setValue('username',$this_user);
}


function hasWhiteSpace($string)
{
        return (strpos($string, ' ') > 0);
}

function name__validate(&$record, $value, &$params){
   $result = hasWhiteSpace($value);   // This is line 17
    if ( $result ){
        $params['message'] = 'The distribution list must not contain spaces';
        return false;
    }
    return true;
}
}
?>


Re: I'm confused

PostPosted: Thu Jul 05, 2012 12:32 pm
by shannah
You defined hasWhiteSpace() as a method of the delegate class - not as a global function. Therefore it needs to be called like
Code: Select all
$this->hasWhiteSpace()

not
Code: Select all
hasWhiteSpace();


-Steve