Welcome Guest, Not a member yet? Register   Sign In
form_validation return after first field error ?
#1
Question 
(This post was last modified: 02-16-2019, 02:42 PM by Ernestas.)

Hi, so recently i started to use CI, and im at a point where i need to validate my forms and i have a question

Is there a good reason for this code ?
Code:
if ( ! isset($this->_error_array[$row['field']]))
{
    $this->_error_array[$row['field']] = $message;
}

return;

(Line 814 @ system/form_validation).

I don't want to piss off visitors with just one error of specific field at a time, i want to show then all.

Quote:I want to get this:
 ["xxx"]=>
 array(2) {
   [0]=>
   string(72) "The xxx field must be at least 3 characters in length."
   [1]=>
   string(72) "The xxx field does not match the yyy field."
 }

Not this:
 ["xxx"]=>
 array(1) {
   [0]=>
   string(72) "The xxx field must be at least 3 characters in length."
 }

So from the code above i'm now using only this
Code:
$this->_error_array[$row['field']][] = $message;

i don't like to mess with core code, so is this the right approach ? maybe im missing something ?

--
sorry for English Smile
Reply


Messages In This Thread
form_validation return after first field error ? - by Ernestas - 02-05-2019, 01:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB