How to Get Form Validation Errors as an Array in CodeIgniter
Post by
on March 21, 2013There are many suggestions for getting CodeIgniter form validation errors as an array (see this StackOverflow thread and this one). However, I do not like them because they all involve extending the validation library or adding a function to the form helper.
The solution I like is as follows:
$validator =& _get_validation_object(); $error_messages = $validator->_error_array;
This allows you to grab the errors whenever you like wherever you like. And, since I keep forgetting how to do this, I'm making a note here.