PmWiki

Forms-Talk

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:)
    (:e_preview:)
    (: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="Guardar" :) (: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: Cookbook:InputJumpBox

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(this.name.indexOf('-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(this.name.indexOf('-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:)
[[#dropdownlist]]
(:input select name=n {=$FullName} "{=$Name}":)
[[#dropdownlistend]]
(:if:)

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

A group page navigator:

>>display=none<<[@
[[#navigator]]
(:if equal {=$FullName} {*$FullName}:)
(:input select name=n  selected=selected {=$FullName} "{=$Name}":)
(:if ! equal {=$FullName} {*$FullName}:)
(:input select name=n {=$FullName} "{=$Name}":)
[[#navigatorend]]
@](:nl:)>><<

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

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.

Comments

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


Sandbox

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:)



(:Message:
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.


This is a talk page for improving PmWiki.Forms.