2008年9月18日星期四

Fwd: [fw-mvc] Zend_Form - rendering form level errors

Hi all

I'm still seeing this error with 1.6.1.  You can clear it by doing an empty() check (or equivalent) on $errors in Zend_View_Helper_FormErrors::formErrors(), but am I missing something?

- Neil

---------- Forwarded message ----------
From: Greg Frith <greg@dgfsolutions.co.uk>
Date: Thu, Apr 10, 2008 at 11:45 AM
Subject: [fw-mvc] Zend_Form - rendering form level errors
To: fw-mvc@lists.zend.com


Hello again!

I'm sorry to keep pestering the group with Zend_Form questions, but the project I am currently working on makes pretty heavy use of forms, and by trying to do everything properly with Zend_Form, I'm giving the modules and my brain quite a work-out!

My next issue relates to the display of error messages following form validation by various built-in and custom validators.  Rather than display errors next to each form field (which I can do without problems), I want to display a list of errors at the top of the form.  I have added the 'Errors' decorator to my form using a config which starts like this:

<form>
<name>logIn</name>
<class>login</class>
<action>/login</action>
<method>post</method>
<description>Please log In</description>
<prefixPath>
<element>
<prefix>UKTickets_Form_Element</prefix>
<path>UKTickets/Form/Element/</path>
</element>
</prefixPath>
<decorators>
<formelements>
<type>FormElements</type>
</formelements>
<desc>
<type>Description</type>
<options>
<tag>h2</tag>
<placement>prepend</placement>
</options>
</desc>
  <errors>
<type>Errors</type>
</errors>
<form>
<type>Form</type>
</form>
</decorators>
<elements>
<email>
.....

Now, when I render the form for the first time all is well.  However, once the form is submitted and I receive validation errors, the following warning is output (appearing where I would expect to see errors), and no error messages are rendered:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /var/www/wetbshared /libs/Zend/View/Abstract.php on line 786

With the following stack trace:

{main}( )

Zend_Controller_Front->dispatch( )

Zend_Controller_Dispatcher_Standard->dispatch( )

Zend_Controller_Action->dispatch( )

Zend_Controller_Action_HelperBroker->notifyPostDispatch( )

Zend_Controller_Action_Helper_ViewRenderer->postDispatch( )

Zend_Controller_Action_Helper_ViewRenderer->render( )

Zend_Controller_Action_Helper_ViewRenderer->renderScript( )

Zend_View_Abstract->render( )

Zend_View->_run( )

include( '/var/www/uktickets3.wharfe.local/www/application/modules/default/views/scripts/login/login.phtml' )

Zend_Form->__toString( )

Zend_Form->render( )

Zend_Form_Decorator_Errors->render( )

Zend_View->formErrors( )

Zend_View_Abstract->__call( )

call_user_func_array ( )

Zend_View_Helper_FormErrors->formErrors( )

Zend_View_Abstract->escape( )

call_user_func ( )

Any help greatly appreciated

:wq

Greg Frith.


没有评论: