Hi celtek:

Hi, I have a script responsible for validation and when an error occurs it will be return : #return RESPONSE.redirect('show_zpt?formErrors=%s&value2=%s' %(error, value2))


First better try not to do a redirect, but return the page directly;
if You use a redirect You can only pass the error dictionary as a string.

Saying:

 context.REQUEST.set('formErrors', error)
 context.REQUEST.set('value2', value2)
 return context.show_zpt()

should call the page directly and allow to pass the dictionary as is.
Alternatively You can say

  return context.show_zpt(formErrors=errors, value2=value2)

and then get the parameters via options/formErrors instead of 
request/formErrors.
(unless I am mistaken here.)

then in 'show_zpt' it will be use :
<!--
<div tal:condition="request/formErrors|nothing" class="portalMessage" 
tal:content="request/formErrors"></div>
-->
and message:
{'surname': 'Input is required but no input given.'}

but I don't want to have this message format, it would be better to have 
something like this:

surname: Input is required but no input given. - without this additional marks!


Yow: when passing in the errors dictionary directly, You should be able to say 
something like:

   <div tal:condition="options/formErrors|nothing">
       <h3>Form validation errors</h3>
       <dl tal:define="errors options/formErrors">
         <tal:block repeat="err errors/keys">
           <dt tal:content="err" />
           <dd tal:content="python:errors[err]" />
         </tal:block>
       </dl>
    </div>

The details depend on Your data structure, of course.

 Most probably You want to loop over the fields of Your form and check
if there is an error for the given field, so the errors appear in the same order
and the fields (the order is pretty undefined for the dictionary ...)

Cheers,
Clemens

P.S. If not found already, a ZPT + Formulator intro
     is here: http://www.zope.org/Members/beno/HowTo/Formulator_With_ZPT
_______________________________________________
ZPT mailing list
ZPT@zope.org
http://mail.zope.org/mailman/listinfo/zpt

Reply via email to