[pmwiki-devel] Question about Forms & Actions

Ben Stallings Ben at InterdependentWeb.com
Mon Dec 11 10:05:57 CST 2006


Hans wrote, quoting me:
>>        return "(:input form
>> > action=$ScriptUrl?n=$pagename$u$o:)\n(:input
>> > hidden action zap:)\n(:input hidden ZAPkey $x:)\n";
> 
> I would probably write (but it may be all the same):
> 
> return "(:input form $ScriptUrl post:)
>         (:input hidden n $pagename$u$o:)
>         (:input hidden action zap:)
>         (:input hidden ZAPkey $x:)";

Beyond the line breaks, it's not the same, because $ScriptUrl only gets 
you the URL of pmwiki.php, while $ScriptUrl?n=$pagename gets you the URL 
of the page.  Maybe there's a more elegant way to get the URL of the 
page, but $ScriptUrl is not sufficient.

Thanks for specifying "post" in there, Hans -- can't take for granted 
that all browsers will assume a form is method="post".  But I believe 
that's included in the $u variable.

Caveman wrote,
> (Ben, did you check this?  I thought ZAP automatically stripped off
> any GET values beyond the page name...)

I'm sure it does, when ZAP runs, but when the form is submitted to a URL 
that includes ?action=edit, ZAP doesn't get a chance to run, because 
PmWiki sends the $_POST data to UpdatePage() instead.  So to reiterate, 
what I'm saying is that the form needs to specify the URL explicitly so 
that the browser won't tack ?action=edit onto it.

I realize I may be the only person who's ever tried putting ZAP in an 
EditForm, but once you see it in action, so to speak, you'll all want to 
do it.  ;-)

Caveman wrote,
> Thanks Hans, that helps.  So theoretically if I implemented Ben's
> suggestion, making it possible to set an action parameter in the form
> field, one could do both server side processing (say of a cgi script)
> simultaneously with whatever zap actions are called.

I believe it's an either/or proposition: either you send the data to a 
URL that's processed by PmWiki, or to another script.  But yes, you 
could use a ZAP form to retrieve data and submit it to an external 
script, which could be very useful for data-processing tasks that are so 
specialized they don't justify writing a recipe.

> Anyone know how this might affect the HandleBrowse and/or Redirect
> code in ZAP?  That is, are Pm's actions done before the form action?
> And if so, would the server action override ZAP's closing actions or
> would the server be ignored?

Not sure we're using the same terminology yet... again, we've got two 
different things called "action" here: one is in the HTML form tag and 
determines the URL the form is submitted to; the other is handled by 
PmWiki.  The first one is much more fundamental than the second, since 
it determines whether ZAP runs at all.  Once you've got your data into a 
page that runs ZAP, then you can worry about HandleBrowse and Redirect. 
  Don't know if that's the answer you were looking for.  --Ben S.



More information about the pmwiki-devel mailing list