• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code for feature request (validation_errors_array())

#1
[eluser]Pnux[/eluser]
Since im not sure how much uservoice likes code on their site, im pasting the code here since its a really simple one. It also might be useful for somebody else.

Code:
// ------------------------------------------------------------------------

/**
* Validation Error Array
*
* Returns an array with all errors associated with a form submission.
* This is a helper function for the form validation class.
*
* @access public
* @return array
*/
if ( ! function_exists('validation_errors_array'))
{
function validation_errors_array()
{
  if (FALSE === ($OBJ =& _get_validation_object()))
  {
   return false;
  }

  return $OBJ->_error_array;
}
}

Example output:

Code:
array(3) {
  ["name"]=>
  string(29) "The Name field is required."
  ["lastname"]=>
  string(31) "The Last Name field is required."
  ["id"]=>
  string(32) "The ID field is required."
}

The idea is not to promote my request in here, so with anything related to the request itself, please use http://codeigniter.uservoice.com/forums/...f-a-string

If you want to use the code, you need to place it on ./system/helpers/form_helper.php. This could also be added to [MY_]Form_validation, but since validation_errors() is a function in the helper, i decided to go there for this one as well.

#2
[eluser]Aken[/eluser]
You should submit this as a pull request on CodeIgniter's Github if you can.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.