如何将数据从控制器传递到Codeigniter中的for_validation配置文件?

im using a config form_validation.php, how can i send a variable from controller to this file (form_validation.php) ?

In my form_validation.php i have:

 array(
    'field' => 'edituser_email',
    'label' => 'Email',
    'rules' => "required|trim|xss_clean|valid_email|edit_unique[users.email.$user_id]",
    'errors' => array(
             'required' => 'Campo obligatorio.',
             'valid_email' => 'Formato de correo no válido.',
             'edit_unique' => 'Ya existe un usuario con este correo.'
              )
    )

i need send "user_id" variable through Controller.

I already tried with:

$data['user_id'] = $id;
if ($this->form_validation->run('edit_user',$data) === FALSE)

But I get errors :

Message: Undefined variable: user_id.

Thanks for your help.

No need to pass arguments to $this->form_validation->run() , just set rules before executing it.

$this->form_validation->set_rules('name', lang('title'), 'required|trim');
$this->form_validation->set_rules('description', lang('description'), 'required');
$this->form_validation->set_rules('slug', lang('slug'), 'trim|required|is_unique[categories.slug]|alpha_dash');

 if ($this->form_validation->run() == true)
 {

        $data = array(
            'name' => $this->input->post('name'),
            'description' => $this->input->post('description'),
            'parent_id' => $this->input->post('parent_category'),
            'slug' => $this->input->post('slug'),
            'active' => $this->input->post('active'),
            'private' => $this->input->post('private'),
        );
 }

I don't try, but I think, if you add a variable to array post, like this, it works.

$this->input->post['user_id'] = $user_id;

as documentation here In the documentation if you want to override post data you need to set data first before run validation.

for ex:

$post_data = array_merge(array('user_id' => $id), $this->input->post(NULL, TRUE)); //merge existing post data with your custom field

$this->form_validation->set_data($post_data);

then

if ($this->form_validation->run('edit_user') === FALSE){
  // error view
}
else{
// success view

}