- Code: Select all
$tableColumns['datei'] = array(
'display_text' => 'Datei',
'perms' => 'EVAXTQSFHO',
'input_info' => 'size="40"',
'val_fun' => array(&$this,'validateFun'),
);
and the function:
- Code: Select all
public function validateFun($col,$val,$row)
{
$query = "select datei from table where datei = :name";
$queryParams = array('name' => $val);
$stmt = DBC::get()->prepare($query);
$stmt->execute($queryParams);
$count = $stmt->rowCount();
if ($count == 0)
{
return true;
}
else
{
$this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'alert("Sorry this value \"'.$val.'\" already exists in Datei");');
return false;
}
}
This works fine.
But if I edit the another field, I get the warning 'Datei already exist' after saving.
I can remove the permission 'E 'from filed 'datei', then it works all ok.
But, sometimes I must change the value of 'datei',
therefore I can NOT remove the 'E' permission.
I think, I should do the validation only, if the value of 'datei' has changed?
How can I do this ? Spent several hours, no solution.