Welcome Guest, Not a member yet? Register   Sign In
Auto Load Form Validation Library based on existance of post array.
#7

[eluser]Henry Weismann[/eluser]
Well, I figured doing is better then talking so I gave my first hook a shot...

hooks/Preload.php

Code:
class Preload
{

        function Preload()
        {
        
        }
        
        function load_form_validation()
        {
        
            if(!empty($_POST))
            {
                $CI = & get_instance();
                $CI->load->library('form_validation');
            }
        
        }
}

In config/hoooks.php

Code:
$hook['post_controller_constructor'] = array(
                                'class'    => 'Preload',
                                'function' => 'load_form_validation',
                                'filename' => 'Preload.php',
                                'filepath' => 'hooks'
                                
                                );

In config/config.php

Code:
$config['enable_hooks'] = TRUE;

It preloads the library quite nicely. I also created an url validation library so I can load that when $_GET is !empty. Can anyone else thing of any useful hooks. I'm going to take a look at the wiki for any other useful hooks. I have never seen any hooks around the forum so I'm curious if anyone is using them and how.


Messages In This Thread
Auto Load Form Validation Library based on existance of post array. - by El Forum - 07-24-2009, 08:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB