We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Uniqueness validation over compund field

I am trying to validate a compound field in the model, so I tried:

$this->validate(new Uniqueness(array(
   'field' => 'foreign_id, servers_id',
   'message' => 'The brand is already present on the selected server.'
)));

But Phalcon says:

Column 'foreign_id, servers_id' isn't part of the table columns

Any ideas ?



34.6k
Accepted
answer
$this->validate(new Uniqueness(array(
   'field' => ['foreign_id', 'servers_id'],
   'message' => 'The brand is already present on the selected server.'
)));

Thanks ! Works fine :)