Welcome Guest, Not a member yet? Register   Sign In
Custom validation callback help [SOLVED]
#1

[eluser]Frychiko[/eluser]
I have a callback to check for a unique name in a db:

Code:
function name_unique($str)
{
    $row = $this->Field_model->get_where(array(
        "name" => $str
    ));
        
    if (!$row)
        return TRUE;
    else
    {
        $this->validation->set_message("name_unique", "The %s field already exists");
        return FALSE;
    }
}

This is fine for insertion...

but for updating I need to know the original name also.
(ie. if (name is unique OR original_name == name) return TRUE)

Is their anyway I can pass in this extra info?... without using a class variable or something global..

cheers!
#2

[eluser]Frychiko[/eluser]
Okay, I've already gone ahead and used a class variable and it works fine.
Solved!




Theme © iAndrew 2016 - Forum software by © MyBB