Validate::unique only for user records

Validate::unique only for user records

xnrsisbixnrsisbi Posts: 18Questions: 7Answers: 0

Hi,

i have a validate unique code when adding a record in the database. The problem that i'm facing is that the table have records from different users and of course with validate unique is activated then it checks not only the user records but also all the other users data for unique values.

Is there any way to tell the 'Validate::unique' to only check user data (based for instance on uid field) and check if that user already have that code registered?

thanks in advance for your help

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Good question - currently no, I'm sorry to say there isn't. However, that is a very good suggestion for a future improvement - the ability to provide an anonymous function that will modify the query. I'll add that in.

    In the meant time, you will probably need to provide your own validation method like this that will query the db as you need.

    I'll put this change in for 1.4.1 which I expect to be available next week (all going well with my current office move!).

    Allan

  • xnrsisbixnrsisbi Posts: 18Questions: 7Answers: 0

    Thanks :-)

    Good luck with office move!!!

This discussion has been closed.