Skip to content

Commit 294803f

Browse files
committed
Better Validator:unique logic
1 parent 7115995 commit 294803f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/PHPFUI/ORM/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ private function validate_time(mixed $value) : string
711711

712712
private function validate_unique(mixed $value) : string
713713
{
714-
$class = '\\' . \PHPFUI\ORM::$tableNamespace . '\\' . $this->record->getTableName();
714+
$class = '\\' . \PHPFUI\ORM::$tableNamespace . '\\' . \PHPFUI\ORM::getBaseClassName($this->record->getTableName());
715715
$table = new $class();
716716
// look up the record in the table. Can't be itself.
717717
$condition = new \PHPFUI\ORM\Condition();
@@ -756,7 +756,7 @@ private function validate_unique(mixed $value) : string
756756

757757
$table->setWhere($condition);
758758

759-
return $this->testIt(0 == (\is_countable($table) ? \count($table) : 0), 'unique', ['value' => $value]);
759+
return $this->testIt(0 == (\is_countable($table) ? \count($table) : 0), 'unique', ['value' => $this->record->{$this->currentField}]);
760760
}
761761

762762
private function validate_url(mixed $value) : string

0 commit comments

Comments
 (0)