Check for duplicate fileds in editor

Check for duplicate fileds in editor

GargiucnGargiucn Posts: 41Questions: 13Answers: 0

I've read the discussion https://datatables.net/forums/discussion/12650/check-for-duplicates/p1.
My problem is that I have to compare two fields: the first of course I get from $ val but I did not understand how to get a second field.

        Field::inst( 'contratti.con_date' ),
        Field::inst( 'contratti.con_num' )
            ->validator( function($val, $data) {
                global $db;
                $res = $db
                   ->sql('SELECT COUNT(*) as count FROM contratti WHERE con_num = '.$val.' AND con_date = .....');
                   $count = $res->fetch();
                   if($count !== 0){ 
                    return "Duplicate value ".$val."";
                   }
                  return true;
                         }

Sign In or Register to comment.