Recent Changes - Search:

PmWiki

pmwiki.org

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="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(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.

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


This is a talk page for improving PmWiki.Forms.

Edit - History - Print - Recent Changes - Search
Page last modified on December 21, 2014, at 04:29 AM