Welcome Guest, Not a member yet? Register   Sign In
Validation, multiple instances of %s?
#7

[eluser]xwero[/eluser]
In the new Form_validation library the field is added as a key to the error_array so you could make method in MY_Form_validation.php
Code:
function ajax_error_string($prefix = '', $suffix = '')
    {
        // No errrors, validation passes!
        if (count($this->_error_array) === 0)
        {
            return '';
        }

        if ($prefix == '')
        {
            $prefix = $this->_error_prefix;
        }

        if ($suffix == '')
        {
            $suffix = $this->_error_suffix;
        }

        // Generate the error string
        $str = '';
        foreach ($this->_error_array as $field=>$val) // changed
        {
            if ($val != '')
            {
                $str .= $field.'|'.$prefix.$val.$suffix."\n"; // changed
            }
        }

        return $str;
    }
This is only a very slightly changed version of the error_string method in the library but if you want you can format it to a json string which is much easier to process in javascript.

For the Validation library you will have to change the last part of the run method to get the same result.


Messages In This Thread
Validation, multiple instances of %s? - by El Forum - 10-02-2008, 02:25 PM
Validation, multiple instances of %s? - by El Forum - 10-02-2008, 02:42 PM
Validation, multiple instances of %s? - by El Forum - 10-02-2008, 02:49 PM
Validation, multiple instances of %s? - by El Forum - 10-02-2008, 03:02 PM
Validation, multiple instances of %s? - by El Forum - 10-03-2008, 12:37 AM
Validation, multiple instances of %s? - by El Forum - 10-03-2008, 03:31 AM
Validation, multiple instances of %s? - by El Forum - 10-03-2008, 03:45 AM
Validation, multiple instances of %s? - by El Forum - 11-10-2008, 12:47 PM
Validation, multiple instances of %s? - by El Forum - 11-10-2008, 02:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB