This is actually a set of interrelated plugins, not just one.
Synopsis...#
First you start with...- FormSet - sets default form element values.
- FormOutput - calls the designated handler and displays its output.
- FormOpen - starts the form by emitting the html <form> tag.
Then you put any normal wikitext between the FormOpen and FormClose along with any number of the following form elements.
- FormInput - textbox, radio buttons, check boxes, submit button
- FormSelect - dropdown selection box
- FormTextarea - multiline textarea
Finally you must end your form with...
- FormClose - ends the form by emitting the html </form> tag.
And that's it, if you want you can define any number of forms on one page, just don't nest their FormOpen/FormClose portions. When a form submit button is hit by the user the input/select/textarea elements are sent to the server where the handler gets invoked and the values are available as it's parameters.
The following example uses the form plugins to provide parameters to the CurrentTimePlugin, and displays the result.
FormSet#
The FormSet plugin sets the default date format for a form field format in form testform. This is hidden in normal WikiPage viewing, looks like this:[{FormSet form='testForm' format='EEE, d MMM yyyy mm:ss:HH Z'}]
FormOutput#
FormOutput specifies that the 'handler' (here, the CurrentTimePlugin), should be used to generate some output to display here. While the output is usually built in response to a POST from a form called testform, the populate attribute here hints that we want default information shown (the plugin called) even if no post has yet been made.[{FormOutput form='testForm' handler='CurrentTimePlugin' populate='handler'}]Thu, 9 Feb 2023 14:51:05 +0200
FormOpen#
The third element starts the actual HTML form called testform, there is no visible output from this.[{FormOpen form='testform'}]
What happens on submit?#
When you click on a submit button, the form is posted to the current page. All the Form inputs specified on the page are given to the WikiPlugin defined in the FormOpen invocation's handler parameter. The plugin receives the inputs in a Map of input name-value pairs (just like WikiPlugins always do), performs whatever logic it needs to do, and optionally provides output (see FormOutput). It may also adjust the submitted values.
The form is then redisplayed, with the submitted values (except where adjusted by the handler).
Hope this helps. These plugins are availble as part of the 2.1.127+ version of JSPWiki. Enjoy your spam.
Can I set a value in handler for a input box and display it on the next page? -- GerryLau
I found the answer. Need to pay attention to the order of FormOutput and FormSet. Otherwise your value set in FormOutput will be overwritten by the coming FormSet.
Hi,
I wrote a plugin which processes a form. The problem that i would like to display the result on a new page coming up immediately after submit. I see some solution that saves a new page and gives back a link to the newly created page. But I don't want to store pages, but dynamically generate them.
Any idea? Gergo
--GergelyGulis, 28-Oct-2006
Hi,
Could I get the form to pass the input values to a external server, some where else on the web, or will it only send data to a local plugin?
Barry Beveridge, 11-Jan-2007
Barry, HTML forms have an action attribute that contain any valid URL, but we don't really want people to have the freedom to be returning the content of processed forms to anywhere on the net from a user-edited page simply for security reasons, e.g., someone might fill out a form with private information thinking it's going one place but it's really getting sent somewhere else. Now, if you're a wiki site administrator and want form content sent somewhere else, you can write a plugin handler to receive the form content, then have that handler do the dirty work. This keeps the security intact and allows you to process the output in whatever way you like (and also maintain security in whatever way you like since the handler is within your control).
For example, I've been playing with XML-RPC recently, and it's feasible to have the form handler plugin send its content via XML-RPC to another wiki site, or any other that could receive the XML-RPC transmission. This of course is just one possible approach (with other "web services" possible too), but the way to do this is with your own custom handler.
-- MurrayAltheim, 12-Jan-2007
I don't understand how the form is processed. I want to create some kind of issuetracker, kind of like the NewIdea tracker. I've adjusted the FormOutput example, but I get the message "Cannot instantiate plugin FormHandler". I'm using version 2.5.18.
- When submitting a form, does this mean that automatically a page is created?
- How can I specify the name of the page from field names?
- What kind of handlers are there, which one should I use?
- In the bugreport form I see the bugreporthandler, and another parameter populate='handler'. Is this populate parameter specific to this handler? What other parametes are there?
- I want to create a link to the issuetracker in the new page automatically. I suppose I can do this using a form element value.
- Is it possible to use hidden elements?
--RvW, 08-Feb-2007 ---
RvW,
Looks like you are using a FormHandler from the example. You either need to use the handlers from out-of-box JSPWiki distribution or write your own. If you are writing your own you need to install:
Refer to Installing Plugins page.
Though this was raised long back, still answering for others' benefit & create a knowledge base.
--YogeshN, 06/13/2008
I would like to get a complete list and explanation of ALL the syntax that the Wiki Forms Plugin uses. Can anyone help me?
--Bill Robfogel, 06-Apr-2007
Add new attachment
List of attachments
Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
---|---|---|---|---|---|---|
jpg |
534870_mikkel_1.jpg | 9.8 kB | 1 | 08-Aug-2007 10:54 | 122.161.45.79 |