Welcome Guest, Not a member yet? Register   Sign In
Callback Validation and Multiple Parameters
#8

[eluser]Jason Tan Boon Teck[/eluser]
[quote author="WanWizard" date="1283221599"]It is possible to pass multiple parameters to a function. I have several, for example 'unique':
Code:
$this->form_validation->set_rules('userid', 'User', 'required|unique[users.id]');

Code:
function unique($value, $params)
{
    list($table, $field) = explode(".", $params, 2);

    if ( ! empty($table) && ! empty( $field ) )
    {
        $CI =& get_instance();
        $CI->db->select($field);
        $CI->db->from($table);
        $CI->db->where($field, $value);
        $CI->db->limit(1);
        $query = $CI->db->get();

        if ($query->row())
        {
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }
    else
    {
        show_error('Call to Form_validation::unique() failed, parameter not in "table.column" notation');
    }
}
[/quote]

Hi,

How do you make the show_error to display the error warning in the form?

Thx,

Jason


Messages In This Thread
Callback Validation and Multiple Parameters - by El Forum - 08-30-2010, 02:07 PM
Callback Validation and Multiple Parameters - by El Forum - 08-30-2010, 03:15 PM
Callback Validation and Multiple Parameters - by El Forum - 08-30-2010, 03:26 PM
Callback Validation and Multiple Parameters - by El Forum - 08-30-2010, 04:41 PM
Callback Validation and Multiple Parameters - by El Forum - 08-31-2010, 09:43 AM
Callback Validation and Multiple Parameters - by El Forum - 08-31-2010, 02:03 PM
Callback Validation and Multiple Parameters - by El Forum - 09-02-2010, 06:34 PM
Callback Validation and Multiple Parameters - by El Forum - 09-07-2010, 09:27 PM
Callback Validation and Multiple Parameters - by El Forum - 09-08-2010, 03:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB