Or validator in conjunction with Validate::dbValues()
Or validator in conjunction with Validate::dbValues()
i've a field of my table that i need to be populated with IDs from another table + an arbitrary value ("-1") that means "no record linked"
actually i use Serverside PHP validator ->validator(Validate::dbValues())
but oviusly this will not validate the arbitrary value, how can i add this "or condition"?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
The
dbValues()
method does actually have the option of specifying extra values which are valid, which would do what you are looking for.The 5th parameter passed in can be an array of valid values as shown in the docs.
Allan
Thanks,
->validator(Validate::dbValues(null,null,null,null,['-1']))
was what i was searching for.