CodeIgniter Forums
Form Validation > Extend CI Base - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Validation > Extend CI Base (/showthread.php?tid=20011)



Form Validation > Extend CI Base - El Forum - 06-25-2009

[eluser]Multisnet[/eluser]
When I tried to extend the Form Validation CI base class I faced a problem that I would like to share with you. Perhaps this could be useful to someone, I lost a few hours trying to solve it.


Extending Form_validation CI base class in the usual way won’t work with the rules in a config file.So we need to do this:

Code:
function MO_Form_validation($rules = array())
{
parent::CI_Form_validation($rules);
}

I've discussed this topic in another post

UPDATED!!


Form Validation > Extend CI Base - El Forum - 06-25-2009

[eluser]heat23[/eluser]
I've also spent several hours trying to extend the CI_Form_validation class without any luck!! I don't want to crash your thread, so I'll post my details in a new one


Form Validation > Extend CI Base - El Forum - 06-25-2009

[eluser]stevezissou[/eluser]
Just glanced at your code, but it seems as if you are calling the wrong parent constructor. If you are trying to extend the class 'CI_Form_validation' it would be...

Code:
class MO_Form_validation extends CI_Form_validation {

  function MO_Form_validation( $rules = array() ) {

    parent::CI_Form_validation( $rules );

  }

}



Form Validation > Extend CI Base - El Forum - 06-25-2009

[eluser]Multisnet[/eluser]
Sorry, I did it like you said but I wrote the code wrong here Wink Thanks anyway, I'm going to update it.