Page edit controls

This feature also defines a number of custom types for implementing page edit controls. These are (more are forthcoming):

    (:input e_form:)     
    (:input e_text rows=n cols=n:)
    (:input e_save:)
    (:input e_saveedit:)
    (:input e_cancel:)
    (:input e_minor:)
    (:input e_author:)

However, they only display as controls when viewed with ?action=edit. Thus, an edit page could be formatted with something like:

!!Editing {$FullName}
(:input e_form:)
(:input e_text rows=5 cols=40:) \\
Author: (:input e_author:) (:input e_minor:) This is a minor edit \\
(:input e_save value="$[Save]" :) (:input e_preview value="$[View Pre]":)
(:input end:)

Editing PmWiki.Forms-Talk

(:input e_form :) (:input e_text rows=5 cols=40:)
Author: (:input e_author :) (:input e_minor :) This is a minor edit
(:input e_save value="Save" :) (:input e_preview value="View Pre":)

Custom input controls

This feature also allows wiki administrators to design custom input controls through the $InputTags array. Documentation of this feature will be forthcoming.

See for a custom input tag for instance: Test.JumpBox.

Example: Input text box which clears a value set when clicked (using script with onfocus event): Add to your local config file:

# input text box will keep initial value, unless name contains '-clear'
$InputTags['text'][':html'] = "<input type='text' \$InputFormArgs  
    onfocus=\"if('-clear')!=-1) this.value=''\" />";

Now if you want an input textbox, which will be cleared when clicking it, add to the name '-clear', like:

(:input text box1-clear "Value will clear":)

Or alternatively add to local config:

# input text box will clear initial value, unless name contains '-fix'
$InputTags['text'][':html'] = "<input type='text' \$InputFormArgs  
    onfocus=\"if('-fix')==-1) this.value=''\" />";

Now any textbox will clear when clicked, unless its name contains '-fix', like:

(:input text box2-fix "Value will stay":)

(:input auth_form:)

When someone hits "Save" on a page, we don't want to lose their edits so, any variables that are posted as part of the save get preserved in the AuthForm, so that when they send the password it's just like they were re-posting the page

This is used in Site.AuthForm. Basically it's <form action='{$_SERVER['REQUEST_URI']}' method='post' name='authform'>\$PostVars where $PostVars is a sequence of <input type='hidden' name='...' value='...' /> tags that encode whatever was posted when the auth_form was generated. Essentially $PostVars takes the contents of $_POST and submits them as part of the auth form.

So, here's a dropdown list of pages in the Test group:

(:if false:)
(:input select name=n {=$FullName} "{=$Name}":)

(:pagelist fmt=#dropdownlist group=Test:)

A group page navigator:

(:if equal {=$FullName} {*$FullName}:)
(:input select name=n  selected=selected {=$FullName} "{=$Name}":)
(:if ! equal {=$FullName} {*$FullName}:)
(:input select name=n {=$FullName} "{=$Name}":)

(:pagelist fmt=#navigator group=Test:)
(:if equal {=$FullName} {*$FullName}:)
(:input select name=n  selected=selected {=$FullName} "{=$Name}":)
(:if ! equal {=$FullName} {*$FullName}:)
(:input select name=n {=$FullName} "{=$Name}":)

In the examples above, setting the name to n ("name=n") will make the form navigate to the page identified in the selected value of the input on submission. If you don't want to navigate to the page, try changing the name to something else.


Is it possible to fill the dropdown list with the content of a page (where I have written all the options line by line)? A kind of (:include:) but inside the dropdownlist. Such a feature should be nice for long lists! PhilB? January 29, 2007, at 01:48 AM

What change would be needed in the php script in order to correctly process the "multiple" option in the ? Currently they are listed (thru GET method) as individual name=value1?name=value2 etc and so when the php script processes them it assigns whichever is the last one as the actual value. Thus instead of n values you end up with exactly 1 value, always the last one. The net effect is that form values are not maintained through the submission process. I can figure out how to process it otherwise in php, but I don't know what sort of data structure is being used for that "multiple" option -- is it an array? --Peter Bowers October 28, 2007


Feel free to use the space below to experiment with creating forms.

(:input form vtest :)
(:input select name=test value=1 label=test1:)
(:input select name=test value=2 label=test2:) \\\
(:input text name=comment value="test12":)
(:input radio foo 1 xyz:)
(:input radio foo 2 abc:)
(:input submit:)
(:input end:)

Can a textarea's default value 
have a line-break in it?"
(:input defaults source=PmWiki.Forms:)
(:input textarea name=$:Message rows=4:)

Yes! It works now.

General field attributes (see their counterparts in HTML forms for a more detailed description)

  • (:input ... focus=1:)

Setting focus=1 causes that field to receive the initial focus when the form is first opened.

  • (:input ... readonly=1:)

Setting readonly=1 causes that field to be displayed but the user cannot change the value

  • (:input select|checkbox|radio selected=1:)

Setting selected=1 causes that selection or checkbox or radio button to be selected.

  • (:input ... secure=1:)

This appears to md5-hash the contents of the field.

  • (:input ... id=X:)

This manually sets the id attribute of the field.

  • name

Sets the name of the field (see above)

  • value

Sets the value of the field. (see above) (For checkboxes, submit buttons, etc this is the value the field will contain if the checkbox is checked or if the button has been pressed. For submit buttons this is also the label displayed on the button.) How does this interract with the (:input defaults:)? Which "wins"?

  • class=classname

Default is "inputbox" for textbox.

  • rows=n

How many rows (lines) the element will occupy (normally used for textarea and select fields)

  • cols=n

How many columns are visible (how wide the field appears).

  • size=n

This is largely analogous to cols=n

  • maxlength

The contents of the field will be limited to this maximum number of characters.

  • action

I believe this is only on the (:input action={$FullName} ...:) specification...? And so probably doesn't belong here?

  • method

I believe this is only on the (:input form method=GET:)...? And so probably doesn't belong here?

  • accesskey=c

A control key which can be pressed to go to that field. For instance, accesskey=u allows a user to press ALT-U (in windows) to select that item.

  • tabindex=n

Allows the order of the fields (when traversing with tab or shift-tab) to be manually specified.

  • multiple=1

Allows multiple items to be selected in a SELECT field

  • checked

Indicates that this checkbox (or radio button) is selected

  • disabled

The field will be greyed-out in some manner and the user will be unable to modify the value in any way.

  • readonly

The user will be unable to modify the value in any way.

  • enctype
  • alt

An alternate text that will be displayed if the browser cannot properly render the field. Also used for accessibility in some cases.

Checkboxes for updating PTVs

Checkboxes only send a value if checked, whereas they send just nothing when not checked. So, there is no way to update/zero an already set value just by unchecking a checkbox. There is an easy and well-working hack though:

(:input hidden $:checkbox_hack 0:)
(:input checkbox $:checkbox_hack 1:)

More on the matter on this short thread. Luigi 21 December 2014

Is there any syntax to generate <button> tag?

I want to generate buttons like this, is it possible in any way?

Finar September 06, 2019, at 11:28 AM

No, you need to add a custom markup, something like this:
  Markup('(:btn:)', 'inline',
    '/\\(:btn(.*?):\\)(.*?)\\(:endbtn:\\)/', 'MyFmtButton');
  function MyFmtButton($m) {
    return "<button ".PQA($m[1]).">{$m[2]}</button>";
Then in the page, use (:btn class="btn btn-primary btn-sm" disabled=disabled data-role="something" title="Tooltip title":)Label(:endbtn:) --Petko September 06, 2019, at 03:54 PM

Q: Is there any possibility to send the form action to a target="_blank"?

I already tried (:input form "https://…" post target="_blank":) but that's not the way. Matthias D? May 06, 2020, at 09:22 AM

Only if you don't use Cookbook:PmForm which uses "target" for something different. Add to config.php:

function CustomInputAttrs(){
  global $InputAttrs;
  $InputAttrs[] = "target";
$PostConfig['CustomInputAttrs'] = 400;

I'll think how to make both compatible -- probably deprecate the PmForm "target" attribute for something else, to allow regular forms to use it. --Petko May 07, 2020, at 05:38 PM

Couldn't believe it working, because it never ever didn't look like :-) but it does wonderfully 👍 Perfekt! Thanks! 🙋🏻‍♂ Matthias D? May 07, 2020, at 07:24 PM

This is a talk page for improving PmWiki.Forms.