I am working with Codeigniter 3, I have a config file (form_validation.php) in which I have all my validation rules.
Within my configuration file (form_validation.php) I have a method that needs to receive a variable (in this case the user_id) here the code -
$config = array(
'edit_user' => array(
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.'
)
)
)
);
But I can not send the variable ($ user_id) from my controller -
$data['user_id'] = $id;
if ($this->form_validation->run('edit_user',$data) === FALSE)
I get an error: Message: Undefined variable: user_id
Some of you have tried to do this, I know that from the method in my Controller, I can add all my rules; but I want to keep these rules separate, using a config file.
Thank you very much for your attention.