[eluser]Twisted1919[/eluser]
Code:
if ( ! function_exists('_get_validation_object'))
{
function &_get_validation_object()
{
$CI =& get_instance();
// We set this as a variable since we're returning by reference
$return = FALSE;
if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
{
return $return;
}
$object = $CI->load->_ci_classes['form_validation'];
if ( ! isset($CI->$object) OR ! is_object($CI->$object))
{
return $return;
}
return $CI->$object;
}
}
And the access to the validation object in your functions:
function form_error($field = '', $prefix = '', $suffix = '')
{
if (FALSE === ($OBJ =& _get_validation_object()))
{
return '';
}
return $OBJ->error($field, $prefix, $suffix);
}
Maybe you can take a look at the form_helper.php, it has it all