Using a DB validator in Zend_Form

Doing some work on a little project of mine while waiting for the keynote to start. What I’m doing is writing a form that needs to make sure that a record is unique in the DB. Doing that in ZF is really easy. Simple set your validator as Db_NoRecordExists. What this does is during the Zend_Form::isValid() functionality it will query the database as part of the validation process. The only parameters you really need are the table and the field if you have already set a default adapter for your Zend_Db models. That makes it really easy to use. Here’s a slice of how I did it.