[pmwiki-users] PmForm DataForm with input select

Mateusz Czaplinski czapkofan at gmail.com
Tue Sep 18 15:30:16 CDT 2007


On 9/15/07, Pico Ben-Amotz <pmwiki at ben-amotz.com> wrote:
> On 9/15/07, Ben Stallings <ben at interdependentweb.com> wrote:
> > If you don't want to navigate to the page, try changing the name of the
> > input to something other than "n".  Best of luck!  --Ben
> >
> That works.  Thank you.  I added a note to the documentation at
> PmWiki/Forms.  I'd like to understand this better, is it part of the
> standard html input , or the DOM select?  Are there other reserved
> names that determine the resulting actions.
>
The 'n' argument is used by PmWiki so that it can be informed which
page you want to see. In a standard out-of-the-box PmWiki
installation, when you want to see page, say, "PmWiki.PageLists", you
navigate your browser to:
  http://example.com/pmwiki.php?n=PmWiki.PageLists
- note the 'n=' part here! PmWiki engine (and many other internet
scripts as well) often choose not to recognize whether some variable
input comes from a html <form> or from the URL (those two methods of
input are called POST and GET methods). Therefore passing some value
assigned to 'n' variable to PmWiki, whichever the method, instructs
the wiki script to load and display specified page.

Similar "magic" variables you can use/avoid can be for example:
- action - chooses whether a page should be viewed ('browse'), edited
(edit), history shown (diff), attributes changed (attr), you want to
encrypt some password (crypt), you want to log in (login), you want to
search for some page (search),.... have I forgot something? :)
- q - when used with action=search, specifies the query (e.g. words) to search.
And there may be some others, yes. :) Especially some Cookbook recipes
can add new ones.

> Now that I've got it working there is one more thing I'd like to try
> to figure out: is there a way to cause the saved page text variables
> to be appended, rather than overwritten, as new values are selected on
> subsequent posts, so that the first post saves Value1 and the second
> post saves Value1 Value2, etc.
>
> Here is what I have in my template:
>
> [[#dataform]]
> (:input pmform target=savedata :)
> (:input default source={*$FullName} :)
> (:input default request=1 :)
> || People:||(:pagelist fmt=#ddpeople group=people:) ||
> || Places:||(:pagelist fmt=#ddplaces group=places:)||
> (:input submit :)
> (:input end:)
> [[#dataformend]]
>
> [[#datapost]]
> (:template defaults where=below savevars=$:people,$:places:)
> [[#datapostend]]
>
> [[#ddpeople]]
> (:input select $:people [[{=$FullName}|{=$Name}]] "{=$Titlespaced}":)
> [[#ddpeopleend]]
>
> [[#ddplaces]]
> (:input select $:places [[{=$FullName}|{=$Name}]] "{=$Titlespaced}":)
> [[#ddplacesend]]
>
If I understand you correctly, try to get a look at the "Comments"
example in PmForms. It appends some text to the end of the page with
every Submit-button-press. The difference there is that the names used
for form fields don't have the '$:' at the beginning and there's no
'savevars'. Instead, the part corresponding to #datapost in your
example uses {$$field-name} to retrieve the values, and the section
between [[#datapost]] and [[#datapostend]] should be a template which
will be appended to the page on each submission.

'savevars' replaces text in the target page (while {$$variables} in a
template are appended) and saves them in special format called
PageTextVariables. It has some advantages and special uses, and AFAIK
there can be only one page variable with a certain name on a page (and
it can have only one value).

Hope that helps :)
Mateusz Czaplinski



More information about the pmwiki-users mailing list