Currently Im developing on a website with Zend framework.
I needed to develop a location field similar to the one found here: http://www.truelocal.com.au/
Which allow user to input PostCode Values (consist of 4 numbers) or Suburb Name
I’m stuck at the moment in the Zend form validation part
Basically I need to ensure the Postcode values or Suburb Name exist in the database.
I’m able to use Zend_Validate_Db_RecordExists easily to check if the Postcode exist in my database.
$validator = new Zend_Validate_Db_RecordExists('postcodeTable', 'postcode');
But how can I also add another Suburb name Validation to check if Suburb Name exist in the database (Without conflicting with the Postcode validation check)?
Is there a clear and easy way to achieve this?
Do I need to write a custom validator? If so how can I do it?
Thanks so much in advance 🙂
I don’t think you can alias validators, like you can decorators, but you could extend Zend_Validate_Db_RecordExists, for example:
Don’t forget to add your library’s validator prefixPath to the element e.g.
Then you can add both validators with different options.