Hi all, I need some ideas on this one. We all know pretty well that a model gathers messages from failing validation rules whenever it performs validations, and these messages can be retrieved using $Model- >invalidFields(). I was thinking, what if I wanted to check if a particular validation rule was triggered for this field that I'm interested in? Would there be a way to check that this rule was triggered without relying on the validation messages?
Let's say I have a registration form. I have a User.username field that has some few validation rules (not empty, between range, valid characters, no duplicates, etc.) but I'm particularly interested if the "no duplicates" rule was triggerred on validation. In a component, whenever the "no duplicates" field is triggered, the component will inject a "username suggestion helper" into the parent controller. The reason why we should not determine if a particular rule was triggered using the validation messages, is because these messages (that are displayed to the user) may be changed in the application, depending on the requirements. These messages are also translated according to the user's current locale, so comparing a validation message that may change in the application's lifetime to its Gettext'ed counterpart is not viable. Would it be possible to mimic the $Model->invalidFields() method to return constant "error codes" or "error ids" (alphanumeric, hashed, numeric, prefixed, or any other flavor you like to site as an example) that would not change even if the associated validation messages change? If so, what's your recommendation on how to wire this functionality into the model so I can check it after validation failures? Thanks, OJ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php