Easily create HTML forms and collect the data via email or use it to create pages.
Compatible with DokuWiki
Similar to conform, contact, contactmodern, form
The bureaucracy plugin allows you to create a HTML form right within DokuWiki. Input format validation is automatically handled by the plugin and requires no coding. User input can be emailed to a preconfigured address or used to create new pages using a template.
Download and install the plugin using the Plugin Manager using the download link given above. Refer to Plugins on how to install plugins manually.
You might want to use the CAPTCHA plugin to avoid automated spam. The swiftmail plugin may help when your DokuWiki can't send mails. This plugin can be used to gather data for use with the data plugin.
An additional plugin to look at is the pagemod plugin which uses the bureaucracy plugin to add data to an existing page (in addition to the current templating and mailing functionality)
Without the CAPTCHA, this plugin should only be used on closed wikis, because it could easily be abused as a spam gateway.
Let's start with an example:
<form> Action mail me@example.com Thanks "Thanks for submitting your valuable data." Fieldset "A set of fields" Textbox "Employee Name" "=Your Name" number "Your Age" >13 <99 email "Your E-Mail Address" textbox "Occupation (optional)" ! password "Some password" fieldset "even more fields" select "Please select an option" "Peaches|Apples|Oranges" static "Some static text that could be an agreement" yesno "Read the agreement?" textarea "Tell me about your self" textbox "You need to write 'agree' here" /^agree$/ submit "Submit Query" </form>
As you can see, you can define a email address where the data should be sent to and a thank you text to be shown when a user submitted the form. What follows are the various fields to fill in.
Fields are defined by giving a type and a label. For fieldsets and the submit button, the label is optional. Some fields like the select type need a third parameter. Additional constraints can be added after the main options.
The plugin takes care of validating the form the field types and set constraints.
Arguments need to be wrapped in double quotes when they contain spaces.
mail, template and pagemod (if this plugin is installed).mail:template:”=some value”)page_tgt based on a template page page_tpl> followed by a number to require numeric data bigger than the given number< followed by a number to require numeric data smaller than the given number= to set a default value! char to make a field optional@ char to make its value be used for the pagename in template mode++ for a number field to make it auto-increment the counter on each form use./ chars to require the the regexp to match before the field is accepted (case insensitive)Sometimes part of a form should only be asked when a certain answer was picked for a previous question. Simple dependencies like that can be created by using Fieldsets.
Consider the following example:
<form> action mail me@example.com fieldset "Your Order" textbox "Your Name" select "What do you want" "Car|Blimp" fieldset "Car Parameters" "What do you want" "Car" number "Number of Wheels" textbox "Extras" fieldset "Blimp Parameters" "What do you want" "Blimp" select "Filling" "Helium|Hot Air" number "Size" fieldset "Confirm Order" submit "Submit Query" </form>
In this example, a user can select to order a car or a blimp. Depending on his choice, the second or third fieldset will be hidden or shown accordingly. The second parameter for the fieldset field references a previously defined field and the third parameter the value that field shall have to display the fieldset. Only exact matches are supported here, so best combine this feature with a select field as shown above.
Sometimes you may want to link to a bureaucracy form and pre-fill one or more fields. This can be easily achieved by adding parameters to your link using @-wrapped field names.
Imaging the form given in the previous section on a page called orderform. Here is how you could link to a form for ordering Hot Air blimps:
[[orderform?@What do you want@=Blimp&@Filling@=Hot Air|Order a Hot Air Blimp!]]
The bureaucracy does three things:
The last step is where the data is processed. What action is to be used is defined in the action field as described above. Currently two modes are supported: mail and template. Additional modes (e.g. for storing the data in a database) can easily be added.
This is a simple action. When used all user input will be sent by email to the configured email address. See the example above how to use it. You may specify multiple mail addresses separated by spaces.
This action uses given pages as template, will replace defined placeholders with the user input and create wiki pages. This is a very powerful, but somewhat complex concept.
The action line looks as follows:
action template [template] [destination] [separator]
template is either a single page, or a whole namespace (with trailing colon). When a namespace is given, all contained sub namespaces and pages will be copied to the destination and replacement patterns will be applied in all pages. When you specify an underscore (_) as template name, the plugin will attempt to use the configured namespace template of the destination namespace.destination tells bureaucracy where to create the new page[s]. This is usually a namespace (trailing colon).separator new page names can be created by using multiple form field values. This character defines how these should be concatenated (see Defining the Output) When using the template mode you need to define where resulting pages should be created. There are multiple ways to do this.
1 The simplest way is to specify an output namespace and mark up your naming fields using the @ character. Here's an example:
<form> action template userstpl users: : fieldset "Create Your User Page" select "What's your Continent?" "Europe|North America|South America|Asia|Australia" @ textbox "What's your Name?" @ textarea "Enter a short bio" ! submit </form>
This would create a new page using the continent and name fields. Eg. if I fill in “Europe” and “Andi” for those fields, the resulting page would be users:europe:andi.
2 Sometimes you want some more control over the resulting pagename(s). This can be achieved by using placeholders in the destination parameter and omitting the @ marker in the field definitions.
Placeholders are the field names surrounded by @@ characters. Additionally any strftime parameters can be used. Let's have another example:
<form> action template userstpl users:%Y:@@What's your Name?@@:start fieldset "Create Your User Page" select "What's your Continent?" "Europe|North America|South America|Asia|Australia" textbox "What's your Name?" textarea "Enter a short bio" ! submit </form>
The above would create a namespace based on the current year and my name and create a start page within it: users:2012:andi:start
3 When working with Dependencies with Fieldsets you might want to add additional pages when a fieldset is shown, but skip the page when the fieldset is hidden. This can be achieved with the special addpage field.
Just put it in the fieldset of question:
addpage additionaltpl somepage
add full example.
The templates need to contain the same fields as your form, surrounded by @@ characters. You may also use ## characters instead of the @@ characters. This makes it simpler to use this plugin with the data plugin.
These placeholders will be replaced by the actual values the user filled into the form.
You may follow the field name with a pipe | char and a default value, should the user not have filled in an optional field.
Additionally you can use all strftime parameters to refer to the current time. Note that you will need to replace all “normal” % chars with %% to avoid accidental time replacements in your template.
For the userstpl from the example above, you could have the following page:
====== @@What's your Name?@@ ====== I'm living in @@What's your Continent?@@. I'm a user since %Y-%m-%d. @@Enter a short bio|FIXME please fill in your biography@@
The result then would look somewhat like this with all the user data filled in:
====== Andreas Gohr ====== I'm living in Europe. I'm a user since 2007-12-23. It's me :-)
By default this plugin will check for ACLs in template mode using the permissions of the user filling the form. This means the user needs to have at least read permissions for the template and create permissions for the namespace where the new page should be saved.
However sometimes you may want to give anonymous users a way to create pages in a restricted namespace without giving them any direct access. This is where the runas option comes into play. With this option you can specify a username in the config manager. The user you specify here will always be used for checking the permissions mentioned above, regardless of the user filling the form. This way you can specify the needed access for this particular virtual user in the ACL manager.
Note: the runas user does not need to exist. In fact it is recommended to use a non existing user. Even when it exists, permission checks are done on user level only, groups of the user will be ignored.
It took me a while to figure out how the checkbox works. Here's my findings:
(!) “Read the agreement?” -box has to be checked.<form> Action mail me@company.com yesno "Are you happy?" ="Yes sir!" yesno "Are you sad?" !"No sir!" submit </form>
| Checked | Result | |
|---|---|---|
| Are you happy? | x | Yes sir! |
| Are you sad? | - | No sir! |
| Are you happy? | - | - |
| Are you sad? | x | - |
| Are you happy? | - | - |
| Are you sad? | - | No sir! |
| Are you happy? | x | Yes sir! |
| Are you sad? | x | - |
— Ciove 2010/08/18
July 3 2011, Selection Box Bug: Not sure if anyone else is having this problem but my selection boxes (drop down lists) are behaving funny and the source seems to be bureaucracy itself. Basically what happens is that they act a bit like a link (nothing happens when you click though) and then there is a small (1-2px) area which is a thin strip across the top of the selection boxes which triggers it to drop down and be selectable. I am very surprised no one else has run into this problem. Here is a brief run down:
.dokuwiki form.bureaucracy__plugin label span, .dokuwiki form.bureaucracy__plugin input.edit,
Specifically the line float: none !important;. If I remove that line the selection boxes (drop down lists) work fine BUT the submit button goes most of the way up the page again. Changing that value to float: left gives the same result, selection boxes are good, submit button is broken.
So does anyone have any brilliant ideas? This seems like perhaps the bureaucracy plugin itself needs to be updated to work with Rincewind…or am I missing something.
FIXED THIS PROBLEM: Fixed it. In case anyone is wondering here is the code. I had to switch another float around form the bureaucracy style.css. Put this code inside tpl/tpl_name/user/screen.css
/* --------------------Bureaucracy Bug Fix------------*/
.dokuwiki form.bureaucracy__plugin label span,
.dokuwiki form.bureaucracy__plugin input.edit,
.dokuwiki form.bureaucracy__plugin textarea.edit {
text-align: left !important;
margin: auto 5px;
float: left !important; /* Part 1 of fix */
width: 96% !important;
min-width: 96%;
max-width: 96%;
}
div.dokuwiki form.bureaucracy__plugin input.button {
margin: 10px; /* Part 2 of fix */
}
div.dokuwiki form.bureaucracy__plugin label input,
div.dokuwiki form.bureaucracy__plugin label .edit,
div.dokuwiki form.bureaucracy__plugin label select {
display: block;
float: none !important; /* Part 3 of fix */
margin-left: 5px;
}
.dokuwiki form.bureaucracy__plugin textarea.edit {
text-align: left !important;
margin: auto 5px;
float: none !important;
width: 96% !important;
min-width: 96%;
max-width: 96%;
}