Basically I have written an input field class with text_field; select_field etc. extending it.
In the parent input_class is a method called "is_valid( )" which tests whether the data entered into the field is valid based on whether the data is of type "string", "numeric", "abn" (AUstralian Business Number), "email", "state" etc.
If I set the data type to any of the above I can get it to work EXCEPT for a data of type "state".
Here is some code:
Code: Select all
if($this->data_type=="state")
{
echo "Line 85";
if(validate_state($_REQUEST[$this->field_name])) return true;
else return false;
}However, if I go into the function "validate_state( )", I can't get even the first line ("Test") to print out.
Eg.
Code: Select all
private function validate_state($state)
{
/*Creates an array storing all the states and territories of Australia */
echo "Test";
$states=array("SA", "NSW", "VIC", "QLD", "NT", "WA", "TAS", "ACT");
for($i=0; $i<sizeof($states); $i++)
{ if ($state==$states[$i])
return true; //Returns true if $state is equal to any state within the $states array
}
return false; //Returns false if $state does not match any of the states within the $states array
}the word "Test" won't print out at all to which I'm buggered if I can work out why??
This function seems to work fine: (yep its a dodgy way to check validity of email I know but it does enough)
Code: Select all
private function validate_email($email)
{
if(!strstr($email, "@") || !strstr($email, ".")) return false;
else return true;
}Sorry about all the excess code but hopefully someone can work out what is going wrong.