11-28-2018, 08:15 AM
Hello,
I want to use a custom function to control an image field.
It works if I use it in the same controller with a callback ...
Exemple in my Administration Controller :
It works.
The problem is that I want to put my validation rule in a Form_validation libraries like this:
And I call now this rules like this :
But I don't understand why it not works ?!
I want to use a custom function to control an image field.
It works if I use it in the same controller with a callback ...
Exemple in my Administration Controller :
PHP Code:
if($config_rules['images'] == true){ $this->form_validation->set_rules('images','images','callback_require_upload');}
function require_upload(){
$CI = $this->CI =& get_instance();
//$CI->load->model('question_model');
$CI->form_validation->set_message('require_upload', "Vous devez uploader une image");
return false;
}
It works.
The problem is that I want to put my validation rule in a Form_validation libraries like this:
PHP Code:
class MY_Form_validation extends CI_Form_validation{
protected $CI;
function __construct($config = array()){
parent::__construct($config);
}
function require_upload(){
$CI = $this->CI =& get_instance();
$CI->form_validation->set_message('require_upload', "Vous devez uploader une image");
return false;
}
}
PHP Code:
if($config_rules['images'] == true){ $this->form_validation->set_rules('images','images','require_upload');}
But I don't understand why it not works ?!