• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved]Custom Validation?

[quote author="brucebat" date="1312331674"]Correct

My function is within the Controller class.

The example uses the $str as an argument,

function username_check($str)


Post the entire controller please. And yes, $str is fine. You could call it $someStupidLongVariableNameThatIProbablyShouldNotUse if you wanted.

Too big for the forum so here is Pastebin Link



Put something like: echo 'got here - inside for loop'; immediately after the opening brace of the for loop.. make sure it's even getting in there.


I don't see a constructor. And is form_validation library auto-loaded?

echo "hello".$i;

Okay tried that and it is working:
So if the user completes three rows I get:


See my edit, sorry.

form_validaiton is autoloaded.

Would a constructor be necessary? From my understanding of constructors in C++ they are used to create class attributes and set values? But in my class there are no attributes being shared in the class?


Not sure if they're required or not... I do know you have to call parent::__construct() if you have a constructor. Not sure if the base class constructor gets called automatically or not. I'd add a constructor & see if it does anything. If not, was only a few seconds lost.

Ok I placed a constructor in the class, should I put anything inside it?

So far its not done anything Smile


public function __construct()
     $this->load->library('form_validation'); // just to test.

Very strange issue, if that doesn't work. I'll have to look at code again.


I am so silly,

I was calling the error reporting before the form_validation was being run.

Okay so the form_validation works and the function is getting called as the "hello world" echo i put it in it is being displayed however it is not giving an error message.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.