CodeIgniter Forums

Full Version: Empty validation_errors()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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.

El Forum

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

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

El Forum

[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

El Forum

[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.

El Forum

[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.