
Tutorials Support > Tutorials? > ProcessingOrder
In developing advanced ZAP forms, it is important to keep in mind the processing order. When a form is submitted, all POST values are appended to the end of the field array *after* the SESSION values. So in the two code examples below, you get different and perhaps unexpected results.
(:zapform:) (:input text buddieslist "+{$AuthId}" size=30:) (:zap savedata="buddieslist":) (:input submit value="Add Me":) (:zapend:)
Normally you would expect this to execute the list command (which adds the user to the existing list) then save the full list. However "buddieslist" is a POST value so it appears in the field array after the savedata field--which is a SESSION value. In the above snippet, ZAP hits savedata first, saves "+Member" and then the "buddieslist" you want is created after--too late! This form could be fixed by doing something like the following
(:zapform:) (:input text postbuddieslist "+{$AuthId}" size=30:) (:zap buddieslist="{postbuddieslist}":) (:zap savedata="buddieslist":) (:input submit value="Add Me":) (:zapend:)
Here, "buddieslist" is executed first, drawing its value from the post value "friends", creating the "buddies" item, and then saving the two fields. Just what you want!
Recap
To recap, here's a summary of the processing order used by the ZAP engine:
- ZAP input fields are processed, in order
- POST values are processed, in order
Several times I have forgotten this processing order rule and it has caused me many headaches! Hopefully this tutorial will save you one or two of your own...