On Thu, Nov 12, 2009 at 7:42 AM, KimG <[email protected]> wrote: > Btw, is $form->addError working in this version of zend? i don't think i see > the error message i try to add in my exception block. > > best regards > > kim
$form->addError works Ok (at least it has as long as I've used it). However, by default the form does not have an error decorator registered to display any errors you add. I have found a couple alternatives: 1) Add the FormErrors decorator to the form itself. I believe this is the accepted method. However it will display all errors on the form (including those that are set on individual fields) and not just the ones added to the form itself in a single block. If you don't remove the Errors decorator from the individual elements, you'll see those errors twice. 2) In your code, add a regular Errors decorator to the form after you call $form->addError. I don't think this is the intended way to use it, but I like it because it allows me to display these errors outside the form while still showing the field-related errors next to the fields as is the default. You just can't add the errors decorator to the form unless you are certain there is an error to display, otherwise you get a notice about passing the wrong argument to htmlspecialchars or (something along those lines). Andrew
