Problems with errors decorator for Zend_Form

3 messages Options
Embed this post
Permalink
umpirsky

Problems with errors decorator for Zend_Form

Reply Threaded More More options
Print post
Permalink
Hi.

Everithing went well with my zend form till I added 'Errors' decorator to it. Then I get

Warning: htmlentities() expects parameter 1 to be string, array given in /usr/local/share/pear/Zend/View/Abstract.php on line 850

when trying to render form with errors in validation.

And getErrorMessages() gives me empty array().

I followed (more or less) http://framework.zend.com/manual/en/zend.form.quickstart.html#zend.form.quickstart.validate

ZF 1.9.5

Any idea?

Regards,
Sasa Stamenkovic.
Andrew Ballard

Re: Problems with errors decorator for Zend_Form

Reply Threaded More More options
Print post
Permalink
On Thu, Nov 5, 2009 at 4:26 AM, umpirsky <[hidden email]> wrote:

>
> Hi.
>
> Everithing went well with my zend form till I added 'Errors' decorator to
> it. Then I get
>
> Warning: htmlentities() expects parameter 1 to be string, array given in
> /usr/local/share/pear/Zend/View/Abstract.php on line 850
>
> when trying to render form with errors in validation.
>
> ZF 1.9.5
>
> Any idea?
>
> Regards,
> Sasa Stamenkovic.
> --
> View this message in context: http://old.nabble.com/Problems-with-errors-decorator-for-Zend_Form-tp26208644p26208644.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>

If I recall correctly, this happens when there are no errors to
display. I seem to recall reading that the Errors decorator was not
intended for forms, but only for form elements; the FormErrors
decorator was added specifically for forms.

I would like to see the error fixed, though. FormErrors seems to exist
to give developers the option to display all errors with the form in a
single location in the document instead of interspersed with the form
elements. The few times I have tried to apply the Errors decorator to
the form itself were because I wanted to display error messages that
were not related to a specific element on the form while maintaining
the interspersed error messages for errors related to individual
fields. In those cases, my workaround was to only add the Errors
decorator to the form after a call to $form->addError(...) to prevent
the warning message.

if (....error condition....) {
    $form->addError('Some error message');
    $form->addDecorator('Errors', array('placement' => 'prepend'));
}

Andrew
umpirsky

Re: Problems with errors decorator for Zend_Form

Reply Threaded More More options
Print post
Permalink
Ah, thanks.

My fault is that I tried to render form with 'Errors' decorator, instead using 'FormErrors'.

Regards,
Saša Stamenković


On Thu, Nov 5, 2009 at 3:35 PM, Andrew Ballard <[hidden email]> wrote:
On Thu, Nov 5, 2009 at 4:26 AM, umpirsky <[hidden email]> wrote:
>
> Hi.
>
> Everithing went well with my zend form till I added 'Errors' decorator to
> it. Then I get
>
> Warning: htmlentities() expects parameter 1 to be string, array given in
> /usr/local/share/pear/Zend/View/Abstract.php on line 850
>
> when trying to render form with errors in validation.
>
> ZF 1.9.5
>
> Any idea?
>
> Regards,
> Sasa Stamenkovic.
> --
> View this message in context: http://old.nabble.com/Problems-with-errors-decorator-for-Zend_Form-tp26208644p26208644.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>

If I recall correctly, this happens when there are no errors to
display. I seem to recall reading that the Errors decorator was not
intended for forms, but only for form elements; the FormErrors
decorator was added specifically for forms.

I would like to see the error fixed, though. FormErrors seems to exist
to give developers the option to display all errors with the form in a
single location in the document instead of interspersed with the form
elements. The few times I have tried to apply the Errors decorator to
the form itself were because I wanted to display error messages that
were not related to a specific element on the form while maintaining
the interspersed error messages for errors related to individual
fields. In those cases, my workaround was to only add the Errors
decorator to the form after a call to $form->addError(...) to prevent
the warning message.

if (....error condition....) {
   $form->addError('Some error message');
   $form->addDecorator('Errors', array('placement' => 'prepend'));
}

Andrew