Welcome Guest, Not a member yet? Register   Sign In
Validation variables missing
#7

[eluser]t'mo[/eluser]
I noticed a similar problem with the Validation's error messages. When I do:

Code:
print_r($this->validation);

from within the Controller class, all the error messages are present. However, when I attempt to do the same thing from within the View, the messages are an empy Array.

I actually need the error messages to show up in the view, so the suggested workaround to check for "isset(...)" won't be very useful.

Update This (http://ellislab.com/forums/viewthread/67539/) looks like the same issue...

Update 2

Works: load Validation class in the Controller method(s) where required, *do not* load
Validation class in either the constructor or autoload.php

Code:
class MyClass extends Controller
{
  function do_stuff()
  {
    $this->load->library('validation');
    // ...setup rules, etc.

    if ($this->validation->run() == FALSE) {
      $this->load->view('view_name'); // view echo's $this->validation->error_string
    }
  }
}

Doesn't work (2 examples):

#1: load Validation class in Controller constructor

Code:
class MyClass extends Controller
{
  function MyClass()
  {
    parent::Controller();
    $this->load->library('validation');
  }

  function do_stuff()
  {
    // ...setup validation rules, etc.; note *absence* of this->load->library('validation')

    if ($this->validation->run() == FALSE) {
      $this->load->view('view_name'); // this->validation->error_string in view will be empty
    }
  }
}

#2: autoload Validation

Code:
// in autoload.php...
$autoload['libraries'] = array('database', 'validation');

And a few further details: running CodeIgniter 1.5.4, Apache 1.3.31 and...
Code:
$ php -v
PHP 4.3.7 (cli) (built: Jun  5 2004 00:11:51)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


Messages In This Thread
Validation variables missing - by El Forum - 12-30-2007, 03:51 PM
Validation variables missing - by El Forum - 12-30-2007, 04:07 PM
Validation variables missing - by El Forum - 12-30-2007, 04:15 PM
Validation variables missing - by El Forum - 12-30-2007, 04:17 PM
Validation variables missing - by El Forum - 12-30-2007, 04:32 PM
Validation variables missing - by El Forum - 12-31-2007, 03:00 AM
Validation variables missing - by El Forum - 01-06-2008, 03:04 PM
Validation variables missing - by El Forum - 01-07-2008, 09:33 PM
Validation variables missing - by El Forum - 01-10-2008, 09:13 AM
Validation variables missing - by El Forum - 01-12-2008, 01:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB