CodeIgniter Forums
Empty validation_errors() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Empty validation_errors() (/thread-31254.html)



Empty validation_errors() - El Forum - 06-11-2010

[eluser]cloudboy82[/eluser]
Hi all, I need some help here. I'm using codeigniter 1.7.2, and using the form validation class (and form helper both auto-loaded). I've used this class before with absolutely no problems, but for some reason there's no longer a validation message...

Code:
$config = array(
            array(
                'field'   => 'username',
                'label'   => 'Username',
                'rules'   => 'required'
            ),
            array(
                'field'   => 'password',
                'label'   => 'Password',
                'rules'   => 'required'
            ),
            array(
                'field'   => 'confirm_password',
                'label'   => 'Password Confirmation',
                'rules'   => 'required'
            ),  
            array(
                'field'   => 'email',
                'label'   => 'Email',
                'rules'   => 'required'
            )
        );
            
    
        if ($this->form_validation->run($config) == TRUE)
        {
            $this->load->view('registration/register-success', $view);        
        }
        else
        {
            $this->load->view('registration/register-index', $view);        
        }

When I output
Code:
<?php echo form_validation(); ?>
on my view, it's empty. When I do a vardump on it, it's string(0) "".

The form validation still runs, however (it checks everything, and if everything validates, it shows my success page), it just doesn't output any errors anymore.

Any help sorting this out would be much appreciated.


Empty validation_errors() - El Forum - 06-11-2010

[eluser]Eric Barnes[/eluser]
I think it should be this:
$this->form_validation->set_rules($config);

if ($this->form_validation->run() == TRUE)


Empty validation_errors() - El Forum - 06-11-2010

[eluser]cloudboy82[/eluser]
Hi Eric,

Thanks for the help. I fixed that in the controller(http://pastebin.com/C1bAUp8R), and tried again, but the validation errors still show up..

You can see the view file here: http://pastebin.com/ErR8be65, as you can see i've tried a validation_errors(); at the top, and a form_error('username') below, and neither work.

The actual page is here...

http://gizmo.robotboy.ca/register


Empty validation_errors() - El Forum - 06-11-2010

[eluser]cloudboy82[/eluser]
I think this has something to do with hooks... I disabled hooks, and now everything works as it should...

Is there any way to get this to work with hooks enabled? Or is there a better way to auto-loading a header/footer onto each page?

Code:
$hook['post_controller_constructor'][] = array(
                                'class'    => 'Header',
                                'function' => 'index',
                                'filename' => 'header.php',
                                'filepath' => 'controllers',
                                'params'   => array()
                                );

$hook['post_controller'][] = array(
                                'class'    => 'Footer',
                                'function' => 'index',
                                'filename' => 'footer.php',
                                'filepath' => 'controllers',
                                'params'   => array()
                                );

I do this to load my header/footer.


Empty validation_errors() - El Forum - 06-11-2010

[eluser]cloudboy82[/eluser]
Haha, I solved my own problem. Thanks for the help tho. In my header file, I was extending a controller when I shouldn't have been.