[pmwiki-users] Fwd: ZAP AddData snippet

The Editor editor at fast.st
Fri Nov 24 05:23:05 CST 2006


---------- Forwarded message ----------
From: The Editor <editor at fast.st>
Date: Nov 24, 2006 6:22 AM
Subject: Re: ZAP AddData snippet
To: admin at obutex.com


On 11/24/06, Jiri Hladůvka / OBUTEX <admin at obutex.com> wrote:
> Hi Caveman,
> I tested AddData snippet on www.zapsite.org
> and
> 1) filled in both fields
> f1 with abc
> f2 with def
>
> all was OK
> but then I filled f1 with xyz and f2 left empty.
> In the source there is now only f1 defined and f2 is lost (erased from
> the source).
>
> Perhaps there should be mentioned that the + feature is applied to F2
> only, so the F1
> stays unchanged if the input field for F1 stays empty and F2 always changes.
>
> Or the F2 input field should be prefilled with the current value.

Ah yes, that is a feature not a bug.  If you use the + parmeter with
savedata, it resaves all the fields already saved on the datapage,
plus the new field(s). (the + fields).  So it won't save F1 unless
it's *already* stored in the datapage...  Once F1 *is* in the
datapage, it will either keep it's current field if F1 is blank, or it
will update it if F1 has a new value.

In other words, suppose you had one data input form which created some
10 data fields.  You would use the regular savedata without the +.
But if on another page you wanted to give the user the option to
change just one bit of data, you would use + and just that one field.
All the otherfields would be automatically preserved.  You could
import all 10 bits of data as hidden fields and resave them that way,
but it's much more hassle.  And then if you ever add another field, or
delete one, you would have to update the updata forms as well to
match.

The problem with the snippet was just that I never added an initial
value for F1 on the page  (as a data value).  I had it fixed on my
home machine but forget to add it to the server. Anyway, it's there
now, and seems to be working as expected. If you retest it, (and check
out the source) you will notice now that whether F1 is blank or
updated, it will be resaved, even though the savedata command just
says +F2.

Thanks for pointing this out.

Cheers,
Caveman


More information about the pmwiki-users mailing list