I have text box in which your adds values in comma separated values. Once the form is post I want to check each of CSV value against database table that if each one of them exist already. If so then I want to throw error message otherwise that is fine.
How can I implement this?
What you need is a custom validator. you can either do it extending
Zend_Validate_Abstractor you can simply use a callback validator.To do so, you need to add this to your element:
And in the same class (usually your form is in a class that extends Zend_Form), you add this method:
See explode() for more information.
However, if your form element is going to be called more than once, and in different forms, then I don’t recommend you to use a callback, but you’d better write your own validator, the theory remains the same though. Take a look here for more information about how to write validators.