• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot extend Form_validation class?

#1
[eluser]Sven Delle[/eluser]
I've created MY_Form_validation.php in application/libraries, and put this into the file:

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation
{
function __construct($config = array())
{
  parent::__construct($config);
}
function error_array()
{
  if (count($this->_error_array) === 0)
  {
     return FALSE;
  }
  else
  {
   return $this->_error_array;
  }
}
}

/* End of file: ./application/libraries/MY_Form_validation.php */

I then load the library (have tried both automatically and manually) in a Controller. But I keep getting:

Quote:Message: Undefined property: MY_Form_validation::$error_array

I simply want the validation_errors as an array as I'd like to handle stuff differently. How can I achieve this in the simplest possible way (I find extending a bit overkill to get something as simple as an array - why is it protected in the first place)?

#2
[eluser]Sven Delle[/eluser]
Yeah, there I did it again; spent an hour trying to fix something I broke.

Forgot (man I hate this) parenthesis at the end of:

$this->form_validation->error_array() <--- yeah, those () were the buggers I forgot.

Christ, get some sleep man!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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