[eluser]acosatom[/eluser]
Hello,
I'm trying to validate a form using groups of rules declared as i indicated at the end.
The problem is that i don't know how showing individual errors for each form field.
I mean, from the controller is possible to know if all group is validated or not:
Code:
if ($this->form_validation->run('datos') == FALSE)
But also need to know which fields, the problem is i don't know how to deal with errors, because if I try it like when i used cascading rules, no read errors.
Code:
if(form_error('nombre')){ echo "Error en el nombre"; }
Assuming that using rule sets i have to declare errors previously for each field, where I do and how? Because this does not work for me:
Code:
$this->form_validation->set_message('nombre', 'Error Message nombre');
Anyone can help me?
Thanks
Code:
//////GROUPS OF RULES IN application/config/form_validation.php////////
$config = array(
'datos' => array(
array(
'field' => 'nombre',
'label' => 'Nombre',
'rules' => 'trim|required|callback_username_check|xss_clean'
),
array(
'field' => 'apellido',
'label' => 'Apellido',
'rules' => 'trim|required|callback_username_check|xss_clean'
),
array(
'field' => 'nif',
'label' => 'Nif',
'rules' => 'trim|required|callback_nif_check|xss_clean'
)
),
'email' => array(
array(
'field' => 'emailaddress',
'label' => 'EmailAddress',
'rules' => 'required|valid_email'
),
array(
'field' => 'name',
'label' => 'Name',
'rules' => 'required|alpha'
),
array(
'field' => 'title',
'label' => 'Title',
'rules' => 'required'
)
)
);