I am working on an app where I am trying to validate a form
submission. If there are any errors when doing the validation, I am
putting the errors into the event, then adding the result. The page
redirects as it should, but the errors do nto exist in the viewstate.
If I take the 'redirect="true"' out of the <result> the errors are in
the viewstate. I know this is possible as this is how I have handled
errors in MG for quite some time.
Here is mg mg.xml block.
<event-handler name="page.subscribe.process" type="public">
<broadcasts >
<message name="needToProcessSubscriber" />
<message name="needToValidateSubscriber" />
</broadcasts>
<results>
<result name="success" do="page.subscribe.success"
redirect="true" /
>
<result name="fail" do="page.subscribe" redirect="true"
preserveState="true" />
</results>
<views>
</views>
</event-handler>
And here is the pertinent code in the controller
<cfset var errors = ArrayNew(1) />
<cfset var subscriber = arguments.event.getValue("subscriber")
/>
<cfset errors = subscriber.validate() />
<cfif arraylen(errors)>
<cfset arguments.event.setValue("errors", errors) />
<cfset arguments.event.addResult("fail") />
</cfif>
Anyone have any idea what I may be doing wrong?
--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en