Dear Agavi Users, i would like to know how best to remove duplicate post data using a custom validator. The scenario is that i am posting a form relating to a 'Contact' entity which has related entities of email addresses.
Currently i have implemented a custom validator with a base="emails[]" and everything is fine until the user inputs for example, the same email address twice. The email entity is looked up twice since the validator runs for each item in the emails[] array. These entities get through to the database and i get a constraint exception in my Contact-Email link table. I would like my validator to detect and skip any duplicates in the posted data, but my validator only seems to have the scope of the current item in emails[]. I guess i could pass the whole emails array as an argument into the validator and loop over each email removing duplicates first, but then i'm not sure how to throw an error with the correct context for an email address that is invalid.. Validator: http://pastebin.com/np1m80ib XML: http://pastebin.com/jjwQdEA5 Please advise. thank you. Hash _______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
