[pmwiki-devel] multiple forms on same page with ZAP ?

The Editor editor at fast.st
Sun Nov 26 06:35:50 CST 2006


On 11/26/06, Christophe David <pmwiki at christophedavid.org> wrote:
> Is it possible to save the data of several forms (ie several submit buttons)
> on the same page using ZAPdata ?
>
> It seems only the data for the last submitted form is saved and the rest is
> lost in the following example
>
> (:zapdata:)
> (:zapform:)
> (:input text "Field1" {$Field1}:)
> (:input text "Field2" {$Field2}:)
> (:input hidden savedata "Field1,Field2":)
> (:input submit value="Zap it!":)
> (:zapend:)
>
> (:zapdata:)
> (:zapform:)
> (:input text "Field3" {$Field3}:)
> (:input text "Field4" {$Field4}:)
> (:input hidden savedata "Field3,Field4":)
> (:input submit value="Zap it!":)
> (:zapend:)
>
> Thank you in anticipation.
>
> Christophe


You can do what you want, but not with these forms.  When you use the
savedata field, it deletes all existing data and then saves only the
specified fields.  So in this case Field1 and 2 would be deleted, and
only Fields3 and 4 would be saved (or vice versa).

To solve this problem you have several options.  One is to retrieve
Fields 3 & 4 in hidden fields in the first form, and then save all
four. Then do the same for the second form (retrieve and save Fields 1
and 2).  If you have secure data you can use getdata to not have to
show their values in the html source.

There is a much easier way (not sure it's documented yet) I just
recently added.  Just add a + to the savedata value, like: (:input
hidden savedata "+Field1,Field2":).  This command tells ZAP to resave
all existing data, overwrite any fields that have been changed in the
form, and add Field1 and 2 if they do not yet exist.  It's a great
shortcut, and preferable to either of the options I suggested above.
Give it a try and let me know if it works for you, as I've only barely
tested it in a few snippets.

Cheers,
Caveman



More information about the pmwiki-devel mailing list