Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

Extend MY_Form_validation not work

$
0
0
I'm locked for extend my form_validation rules...
In my controller I have a function article_new() who have this rules :


PHP Code:
$this->form_validation
    
->set_rules('titre','Titre','trim|required|xss_clean|encode_php_tags')
 
   ->set_rules('image','Image','callback_handle_upload')
 
   ->set_rules('tags','Tags','trim|required|xss_clean|callback_tags|encode_php_tags')
 
   ->set_rules('article','Article','trim|required|xss_clean|encode_php_tags'); 


Here my function handle_upload :


PHP Code:
   <?php
    function handle_upload
()
 
   {
 
       if (isset($_FILES['image']) && !empty($_FILES['image']['name']))
 
       {
 
           
        
}
 
       else
        
{
 
           // throw an error because nothing was uploaded
 
           $this->form_validation->set_message('handle_upload'"Vous devez uploader une image");
 
           return false;
 
       }
 
   }
 
   ?>


My function works well but I want to move this out of my controller.
So I put the function in the MY_Form_validation library located in application/librairies/MY_Form_validation.php.
If I do this, and I remove "callback_" in my rules it doesn't work... and I don't know why Sad
I work with the 2.2.6 version.

Viewing all articles
Browse latest Browse all 14343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>