Building my own module and it works perfectly at the moment. My next step is to add server side validation to the data being inputted by admin in the module form.
I am validating the data in my models _beforeSave method which is fine. its wrapped in a try catch and if the validation fails it adds an error to the session.
Here is that code.
protected function _beforeSave()
{
$data = $this->getData();
$strLengthValidator = new Zend_Validate_StringLength();
$strLengthValidator->setMax(40);
try{
$strLengthValidator->isValid($data['identifier']);
}
catch(Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
I have 2 issues:
1) the error doesn't get saved in the session? Why is this?
2) When i eventually get the error to save in the session, how do i handle it in the controller?
Thanks