views:

54

answers:

1

I'm new to Symfony Framework and I ran into a problem with form validation.

I want to update data in DB including unique column, but if unique column is unchanged, an error is returned (An object with the same "domain" already exist."). Domain column must be unique, but user should be able to change it. So, if one user saves his domain name, no one else can use it, but he can change it in future.

It seems like form validation compares unique column not only to other rows, but to itself too. So if user don't change the column and saves form, error is returned.

What validation should I use to preserve column unique, but free to change?

+1  A: 

If you are using Doctrine and the validator is sfValidatorDoctrineUnique, it should work as intended.

i.e validates if you are updating an object. See line 102.

DuoSRX