CodeIgniter Forums
Extending Form validation Constructor Error - 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: Extending Form validation Constructor Error (/showthread.php?tid=13225)



Extending Form validation Constructor Error - El Forum - 11-15-2008

[eluser]OES[/eluser]
Hi Peeps.

Have any of you come accross this yet.

I can extend Form_validation no problem at all but as soon as I add a constructor it breaks. There are no errors but you do not get your error messages from the function.

IE
Code:
class MY_Form_validation extends CI_Form_validation {

  function MY_Form_validation()
  {
    parent::CI_Form_validation();
  }
}

Removal of the constructor it then works. ?

Any ideas.


Extending Form validation Constructor Error - El Forum - 11-15-2008

[eluser]Pascal Kriete[/eluser]
The config array associated with the class is automatically passed to the constructor. Since your rules are probably stored in the config file, you need to account for that array:
Code:
class MY_Form_validation extends CI_Form_validation {

    function MY_Form_validation($config = array())
    {
        parent::CI_Form_validation($config);
    }
}



Extending Form validation Constructor Error - El Forum - 11-15-2008

[eluser]OES[/eluser]
Hey thanks Inparo.

Perfect.