Tuesday, 16 June 2009

Add custom filters and validators on zend framework

There are a lot of ways to add a custom filter or validator in the zend workspace. Well, to make it simple, you can add specific custom filters or validators on a certain element.

Here's a simple code sets :

First : Create your filters and validators on your library.

mylib->custom->filters
mylib->custom->validators

Second : Open a certain form that will use the your custom filter or validator.
Third : Add the prefix path on the specific element that needs the said filter by :

$this->getElement('elementName')
->addPrefixPath('mylib_custom_validator', 'mylib/custom/validator/', Zend_Form_Element::VALIDATE);
->addPrefixPath('mylib_custom_filter', 'mylib/custom/filter/', Zend_Form_Element::FILTER);

Simple stuffs.. Just to be reminded.. :D

No comments: