Welcome Guest, Not a member yet? Register   Sign In
How to obtaining a group of errors by type, like "required", "numeric", etc.?
#1

[eluser]Isern Palaus[/eluser]
Hello,

My client is not satisfied with the current why I'm showing the validation errors. He don't want to show next to the form so I've to use validation_errors(); function to show it at top of the page.

He's asking me to show errors like:

This fields are required: name, e-mail...
This fields needs to be numeric: code.
This fields needs to be ... : x, y...

There is anyway actually to obtain errors like that? If not, how I can start to get the errors like an array? Any suggestion?

Thank you in advance!!
#2

[eluser]keevitaja[/eluser]
i use flash data for that!

Code:
if(something) {
    $errors[] = 'Message 1';
}

if(something else) {
    $errors[] = 'Message 2';
}

if(something wrong) {
    $errors[] = 'Message 3';
}

if(!empty($errors)) {
    $error = implode('<br />', $errors);
      
    $this->session->set_flashdata('msg', $error);

    redirect('/some/where');
}
#3

[eluser]Isern Palaus[/eluser]
Uhm... I think that you don't get me. I'm using the form validation library and I need to know when various of required fails or various of numeric fails.

How you know what type of error you've?

Thank you!
#4

[eluser]keevitaja[/eluser]
i underestood you. i just wanted to say, i handle the errors my self. this way i can do pretty much everything i want!




Theme © iAndrew 2016 - Forum software by © MyBB