ARC TWiki
>
TWiki Web
>
FormPlugin
(2013-05-04,
TWikiContributor
)
(raw view)
Ra
w
edit
|
E
dit
A
ttach
%IF{"defined Name and $ Name != ''" then="---+!! Hello %URLPARAM{"Name"}%!" else="---+!! Form Plugin"}% <!-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/FormPlugin or provide feedback at http://twiki.org/cgi-bin/view/Plugins/FormPluginDev. If you are a TWiki contributor please update the plugin in the SVN repository. --> %SHORTDESCRIPTION% <sticky><div style="float:right; background-color:#eeeeee; margin:0 0 20px 20px; padding: 0 10px 0 10px"> %TOC{title="Page contents"}% </div></sticky> ---++ Main features * No html knowledge required to create forms * Add input fields, textareas, dropdown select boxes, checkboxes, radio buttons * Set preselected values * Create a uniform layout * Call TWiki scripts (view, edit, upload, save, etcetera) or custom scripts * Use entered field values as variables * Validate the form before it performs its action * Usability tested error feedback * Add Javascript functions for advanced interaction Example of validation error feedback: <div class="twikiImage"><img src="%ATTACHURLPATH%/screenshot_validation_example.png" alt="Example of validation error feedback" width='709' height='483' /></div> ---++ Introduction A simple form can be created like this: <verbatim> %STARTFORM{ name="myform" action="view" }% %FORMELEMENT{ name="Name" type="text" title="Your name:" mandatory="on" }% %FORMELEMENT{ name="action" type="submit" buttonlabel="Submit" }% %ENDFORM% </verbatim> %IF{"not context FormPluginEnabled" then="<!--"}% This results in: %STARTFORM{ name="myform" action="view" }% %FORMELEMENT{ name="Name" type="text" title="Your name:" mandatory="on" }% %FORMELEMENT{ name="action" type="submit" buttonlabel="Submit" }% %ENDFORM% %IF{"not context FormPluginEnabled" then="-->"}% %IF{"not context FormPluginEnabled" then='This plugin is %RED%not enabled%ENDCOLOR% so the form is not created.'}% ---++ Usage <verbatim> %STARTFORM{ name="..." action="..." restaction="..." method="..." id="..." validate="..." topic="..." web="..." anchor="..." redirectto="..." formcssclass="..." elementcssclass="..." elementformat="..." noformhtml="..." passthrough="..." onSubmit="..." sep="..." showerrors="..." noredirect="..." }% %FORMELEMENT{ name="..." type="..." title="..." hint="..." mandatory="..." validate="..." condition="..." options="..." labels="..." value="..." buttonlabel="..." size="..." maxlength="..." rows="..." cols="..." format="..." titleformat="..." fieldformat="..." cssclass="..." focus="..." disabled="..." readonly="..." beforeclick=..." onFocus="..." onBlur="..." onMouseOver="..." onMouseOut="..." onSelect="..." onChange="..." onClick="..." onKeyUp="..." }% %ENDFORM% </verbatim> Most parameters are optional. See below for a detailed explanation. ---++ Parameters ---+++ STARTFORM %TABLE{columnwidths="10%,35%,10%,10%,35%"}% | *Parameter* | *Description* | *Required* | *Default value* | *Example* | | =name= | The name of the form. Must be unique. Will also be used as the id, if =id= is not provided | required |=-=| =name="personaldata"= | | =action= | Action of the form. For example: %BR%\ =view=, =viewauth=, =edit=, =save=, =create=, =rest=, =%<nop>SCRIPTURL{view}%/%<nop>WEB%/WebHome= | required |=-=| =action="viewauth"= | | =restaction= | If =action= is =rest=: the rest function to call; see %SYSTEMWEB%.TWikiScripts. |if =action= is =rest= |=-=| =restaction="<nop>MyPlugin/update"= | | =noformhtml= | When set to =on= no form html will be written to the page. This is useful to set form parameters for form elements that use a different form, for instance with TWiki:Plugins.CommentPlugin. If used, the parameters =name= and =action= are not required. |=-=|=-=| =noformhtml="on"= | | =id= | The id of the form. If not set, the name is used |- | the form name | =id="thisformid"= | | =validate= | Set to ="off"= to disable form validation; overrules any FORMELEMENT =validate= parameters. |- |validation is enabled | =validate="off"= | | =passthrough= | Sometimes, for example when redirecting to a login page during authentication (and then again from the login page to the original requested URL), you want to make sure all parameters are passed on, and for this =passthrough= should be set to =on=. In this case it will pass all parameters that were passed to the current query on to the redirect target. If the request method for the current query was =GET=, then all parameters will be passed by encoding them in the URL (after '?'). If the request_method was =POST=, then there is a risk the URL would be too big for the receiver, so it caches the form data and passes over a cache reference in the redirect GET. NOTE: =passthrough= is only meaningful if the redirect target is on the same server. %BR% \ Useful when creating forms for !CommentPlugin - see Sandbox.FormPluginExamples. |=-=|=off=| =passthrough="on"= | | =topic= | Only if =action= is set to =view=, =viewauth=, =edit=, =upload=, =create= or =save=: the target topic of the action. =Webname.TopicName= syntax may be used. |=-=|the current topic | =topic="%<nop>WEB%.WebHome"= | | =web= | Only if =action= is set to =view=, =viewauth=, =edit=, =create= or =save=: the target web of the action. |=-=|the current web | =web="Main"= | | =anchor= | The anchor link the form should be linked to after successful submission. %BR% \ In case of an error, the default notification anchor link is used to directly point to possible problems (anchor =#<nop>FormPluginNotification=). |=-=| | =anchor="MyForm"= | | =method= | GET or POST ([[http://www.cs.tut.fi/~jkorpela/forms/methods.html][What's the difference?]]) |=-=| =GET= | =method="POST"= | | =redirectto= | Redirect topic after form action has been performed. |=-=|=-=| =redirectto="Main.WebHome"= | | =formcssclass= | The CSS class of the form container. Use CSS classes =twikiFormSteps= and =twikiFormStep= for elements to divide the form in steps. |=-=|=-=| =formcssclass="twikiFormSteps"= | | =elementcssclass= | The CSS class of the element container. Use CSS class =twikiFormStep= class to divide the form in steps. |=-=|=-=| =elementcssclass="twikiFormStep"= | | =onSubmit= | Function call that is invoked when the user has pressed the submit button of a form. This event happens just before the form is submitted, and your function can return a value of false in order to abort the submission. Note that the function call should include =(this)=. |=-=|=-=| =onSubmit="return notify(this)"= | | =sep= | HTML element separator; defaults to =\n= (TML line feed), but can be set to " " or similar to allow FORM to be defined within a table |=-=| ="\n"= | =sep=" "= | | =showerrors= | Position of the error feedback: =above= the form (default), =below=, or =off= (hide). Use =%<nop>FORMERROR%= to display the message elsewhere. |=-=| ="above"= | =showerrors="off"= | | =noredirect= | By setting this to "on", !FormPlugin will not redirect after submitting a form (after validation failure or success). |=-=|=-=| =noredirect="on"= | ---+++ FORMELEMENT =FORMELEMENT= contains: * form field - see paramters below * optional items: * title * div container * hint text * mandatory indication Use =%<nop>URLPARAM{"element_name"}%= to retrieve the value of a submitted form element. ---++++ Attributes %TABLE{columnwidths="10%,35%,10%,10%,35%"}% | *Parameter* | *Description* | *Required* | *Default value* | *Example* | | =name= | Element name, must be unique. May contain spaces. The element name is used in the validation error feedback. | required |=-=| =name="First name"= | | =type= | Type of the element - see below for possible types. |required|=-=|| | =type="text"= | Creates a textfield; use =size= and =maxlength= to set the length. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="comment" %BR% \ type="text" %BR% \ title="Comment" %BR% \ }%= | | =type="textonly"= | Does not use a form field but writes the value as text inside an HTML =span= with class =formPluginTextOnly=. The value is passed when submitting the form using a hidden field. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="name" %BR% \ type="textonly" %BR% \ value="%<nop>WIKIUSERNAME%" %BR% \ }%= | | =type="password"= | Creates a password textfield; otherwise same as =text=. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="pw" %BR% \ type="password" %BR% \ }%= | | =type="upload"= | Creates an upload field; use with =STARTFORM= parameter =action="upload"= and set the =name= to ="filepath"=. |=-=|=-=| =%<nop>STARTFORM{ %BR% \ name="uploadpicture" %BR% \ action="upload" %BR% \ topic="%<nop>WEB%.%<nop>TOPIC%" %BR% \ method="post" %BR% \ }% %BR% \ %<nop>FORMELEMENT{ %BR% \ type="upload" %BR% \ name="filepath" %BR% \ title="Attach profile picture" %BR% \ }% %BR% \ ...= | | =type="textarea"= | Creates a textarea; use params =rows= and =cols= to set the size. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="body" %BR% \ type="textarea" %BR% \ title="Message:" %BR% \ rows="5" %BR% \ cols="80" %BR% \ }%= | | =type="select"= | Creates a variable sized selection box; use param =size= to set the visible number of items; use =options= to pass dropdown values, =labels= to set the option labels, and =value= to set the default selected values. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="friend" %BR% \ type="select" %BR% \ size="5" %BR% \ title="Select friend:" %BR% \ options="mary, peter, annabel, nicky, jennifer" %BR% \ labels="Mary M, Peter P, Annabel A, Nicky N, Jennifer J" %BR% \ }%= | | =type="selectmulti"= | Same as =select= with multiple items selectable; use =options= to pass dropdown values, =labels= to set the option labels, and =value= to set the default selected values. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="friends" %BR% \ type="selectmulti" %BR% \ size="5" %BR% \ title="Select friends:" %BR% \ options="mary, peter, annabel, nicky, jennifer" %BR% \ labels="Mary M, Peter P, Annabel A, Nicky N, Jennifer J" %BR% \ value="mary,annabel" %BR% \ }%= | | =type="dropdown"= | Same as =select= with 1 item visible; use =options= to pass dropdown values, =labels= to set the option labels, and =value= to set the default selected value. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="friend" %BR% \ type="dropdown" %BR% \ title="Select friend:" %BR% \ options="mary, peter, annabel, nicky, jennifer" %BR% \ labels="Mary M, Peter P, Annabel A, Nicky N, Jennifer J" %BR% \ value="peter" %BR% \ }%= | | =type="checkbox"= | Creates a set of checkboxes; to put checkboxes on line each set =fieldformat="$e <br />"=; use =options= to pass dropdown values, =labels= to set the option labels, and =value= to set the default selected values. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="name" %BR% \ type="checkbox" %BR% \ title="Choose a name:" %BR% \ options="mary=Mary M, peter=Peter P, annabel=Annabel A, nicky=Nicky N, jennifer=Jennifer J" %BR% \ fieldformat="$e<br />" %BR% \ value="mary,peter" %BR% \ }%= | | =type="radio"= | Creates a set of radio buttons; to put radio buttons on line each set =fieldformat="$e <br />"=; use =options= to pass dropdown values, =labels= to set the option labels, and =value= to set the default selected values. See also param =dateformat=. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="name" %BR% \ type="radio" %BR% \ title="Choose a name:" %BR% \ options="mary=Mary M, peter=Peter P, annabel=Annabel A, nicky=Nicky N, jennifer=Jennifer J" %BR% \ fieldformat="$e<br />" %BR% \ value="mary" %BR% \ }%= | | =type="date"= | Creates a date button; requires !DatePickerPlugin (installed by default). |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="date" %BR% \ type="date" %BR% \ dateformat="%e-%b-%y" %BR% \ title="Select date:" %BR% \ }%= | | =type="submit"= | Creates a submit button. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="action" %BR% \ type="submit" %BR% \ buttonlabel="Send info" %BR% \ }%= | | =type="hidden"= | Creates a hidden input field. |=-=|=-=| =%<nop>FORMELEMENT{ %BR% \ name="CarbonCopy" %BR% \ type="hidden" %BR% \ default="$Name earns $Salary" %BR% \ }%= | | =options= | List of selectable value parameters to use with =select=, =dropdown=, =checkbox= or =radio=. You may use DataForms notation =option1=Label 1, option2=Label 2=. |=-=|=-=| =options="mary, peter, annabel, nicky, jennifer"= %BR% \ or %BR% \ =options="mary=Mary M, peter=Peter P, annabel=Annabel A, nicky=Nicky N, jennifer=Jennifer J"= | | =labels= |To use with =options=: list of visible labels for each option. |=-=|If no labels are set, the option values are displayed. | =labels="Mary M, Peter P, Annabel A, Nicky N, Jennifer J"= | | =value= |Predefined input: \ %BB% For single entry elements: the text value. \ %BB% For multi-select elements: the default selected items; a comma delimited string. \ %BB% For =type="submit"= the button label; you may use =buttonlabel= as well. |=-=|=-=| =value="%<nop>WIKIUSERNAME%"= %BR% \ or %BR% \ =value="mary, peter, annabel"= %BR% \ or %BR% \ =value="Submit"= | | =buttonlabel= | The button label. |=-=|=-=| =buttonlabel="Submit"= | | =hint= | Input hint optionally displayed next to the form element. |=-=|=-=| =hint="Enter a <nop>%SYSTEMWEB%.WikiWord"= | | =mandatory= | Indicates if the form element needs to have a value or selection when the form is submitted. When submitted the field must not be empty. Creates a red asterisk (unless the =format= is defined differently). |=-=|=-=| =mandatory="on"= | | =validate= | The type of entry this form element needs to have when the form is submitted: \ %BB% =nonempty= single entry elements: must have a value; multi-select elements: must have a selection \ %BB% =string= same as =nonempty=; this will not test if the input is a number, because for Perl there is no difference between string and number \ %BB% =int= the input must be a rounded number \ %BB% =float= the input accepts rounded numbers and floating point numbers \ %BB% =email= the input must be in e-mail format |=-=|=-=| =validate="nonempty"= | | =condition= | Conditionally sets the =value= value of a form field. Used together with =value= parameter and a form field token: =$name_of_form_field=. Use the same parameters as with =validate=. |=-=|=-=| This example will write a bullet item with the value of field =date_from=, only if that value exists: %BR% \ =value=" * $date_from"= %BR% \ =condition="$date_from=nonempty"= | | =format= | See [[#Formatting][Formatting]] below. ||| =%<nop>FORMELEMENT{ %BR% \ name="comment" %BR% \ type="text" %BR% \ title="Comment" %BR% \ hint="anything" %BR% \ mandatory="on" %BR% \ format=" <b>$t</b> $m $h $e" %BR% \ }%= | | =fieldformat= | See [[#Formatting][Formatting]] below. ||| =%<nop>FORMELEMENT{ %BR% \ name="friends" %BR% \ type="radio" %BR% \ options="mary=Mary M, peter=Peter P, annabel=Annabel A, nicky=Nicky N, jennifer=Jennifer J" %BR% \ fieldformat="$e <br />" %BR% \ }%= | | =titleformat= | See [[#Formatting][Formatting]] below. ||| =%<nop>FORMELEMENT{ %BR% \ name="comment" %BR% \ type="text" %BR% \ title="Comment" %BR% \ titleformat=" <b>$t</b> <br />" %BR% \ }%= | | =cssclass= | CSS class for the element |=-=|CSS classes: =twikiInputField=, =twikiSubmit= | =%<nop>FORMELEMENT{ %BR% \ name="Name" %BR% \ type="text" %BR% \ cssclass="twikiBroadcastMessage" %BR% \ }%= | | =size= | For =type="text"= or =type="password"=: the width of the input field measured in number of characters. |=-=|=40= | =size="60"= | | =maxlength= | For =type="text"= or =type="password"=: the maximum number of input characters. |=-=|=-=| =maxlength="12"= | | =rows= | For =type="textarea"=: the number of rows. |=-=|=-=| =rows="5"= | | =cols= | For =type="textarea"=: the number of columns. |=-=|=-=| =cols="80"= | | =focus= | =focus="on"= gives text entry focus to a field. Requires javascript. Only one element on the page can have focus. |=-=|=-=| =focus="on"= | | =disabled= | =disabled="on"= disables user input; copying from a disabled input field is not possible. Note: disabled fields are not included into the submitted data. |=-=|=-=| =disabled="on"= | | =readonly= | =readonly="on"= makes the field read-only; copying is possible but not changing. Only works for text fields and textarea. Note: readonly fields _are_ included into the submitted data. |=-=|=-=| =readonly="on"= | | =dateformat= | Sets the output format of the date button, for instance: =%Y/%m/%d= - see [[#DateFormats][date formats]] for more info. |=-=| Default date format set in [[%SCRIPTURL{configure}%][configure]]'s Extensions section, !DatePickerPlugin settings. || ---++++ Javascript parameters Note that all function calls should include =(this)=. %TABLE{columnwidths="10%,44%,8%,8%,30%"}% | *Parameter* | *Description* | *Required* | *Default value* | *Example* | | =beforeclick= | (Javascript convenience method) Creates default text in a textfield that is 'clicked away' when the field is clicked. |=-=|=-=| =beforeclick="Your name..."= | | =onFocus= | Function call that is invoked when the user has selected a field. |=-=|=-=| =onFocus="makeBlack(this)"= | | =onBlur= | Function call that is invoked when the user has changed the part of a text field that is selected. |=-=|=-=| =onBlur="makeGray(this)"= | | =onMouseOver= | Function call that is invoked when the mouse has moved over an element. |=-=|=-=| =onMouseOver="makeYellow(this)"= | | =onMouseOut= | Function call that is invoked when the mouse has moved off an element. |=-=|=-=| =onMouseOut="makeWhite(this)"= | | =onSelect= | Function call that is invoked when the user has changed the part of a text field that is selected. |=-=|=-=| =onSelect="makeBold(this)"= | | =onChange= | Function call that is invoked when the user has changed the contents of a field. |=-=|=-=| =onChange="giveFeedback(this)"= | | =onKeyUp= | Practically the same as =onChange=. |=-=|=-=| =onKeyUp="giveFeedback(this)"= | | =onClick= | Function call that is invoked when the user has clicked an element. |=-=|=-=| =onClick="beep(this)"= | ---+++ ENDFORM Does not have any parameters. #FormStatus ---+++ FORMSTATUS Retrieve the validation status of the form. Note that the status cannot be used to build form logic (the variable expansion happens long after the form is created), but you may use it to show additional feedback. * Status = =%<nop>FORMSTATUS{"name_of_form"}%= %BR% Possible values: * =unchecked= - the form has not been validated * =error= - the form has been validated and an error has been found * =noerror= - the form has been validated and no errors have been found * unchecked status = =%<nop>FORMSTATUS{"name_of_form" status="unchecked"}%= %BR% ='1'= in case of unchecked, otherwise ='0'= * error status = =%<nop>FORMSTATUS{"name_of_form" status="error"}%= %BR% ='1'= in case of error, otherwise ='0'= * noerror status = =%<nop>FORMSTATUS{"name_of_form" status="noerror"}%= %BR% ='1'= in case of noerror, otherwise ='0'= #FormErrors ---+++ FORMERROR Retrieve the current validation errors - instead of displaying them just above the form. * Errors = =%<nop>FORMERROR{"name_of_form"}%= ---++ Retrieving form values Use [[%SYSTEMWEB%.VarURLPARAM][%<nop>URLPARAM{}%]] to display submitted form values. For example <verbatim> * Name = %URLPARAM{"MyName"}% * Names = %URLPARAM{"MyFriends" multiple="on" separator=", "}% </verbatim> ---++ Formatting Formatting of each form element can be set with the =FORMELEMENT= parameters: * =format= - defines the display of: * title * field * hint * mandatory indicator * =fieldformat= - defines the display of the field / select item only * =titleformat= - defines the display of the title only Use the following tokens to define where form element parts are displayed: * =$e= - form element token * =$t= - title token * =$h= - hint token * =$m= - mandatory token, currently just an asterisk =*= * =$a= - anchor token, where the anchor link should be placed (anchor links are used to link to fields with error feedback) The escape tokens =$quot= ("), =$percnt= (%), =$dollar= ($), =$n= (newline) and =$nop= (<nop>) can be used to prevent expansion. ---+++ =format= Attribute of =STARTFORM= or =FORMELEMENT=. The default =format= is: <verbatim> $a <p> $t <br /> $e $m $h </p> </verbatim> This means that the title is displayed one line above the field, and the mandatory indicator and input hint are displayed at the right of the field. %BR% To swith the order around use for example: <verbatim> format="<p> $m $t $h <br />$e </p>" </verbatim> ---+++ =elementformat= Attribute of =STARTFORM=. The default =elementformat= is simply <verbatim> $e </verbatim> This means that radio buttons and checkboxes are all displayed on one line. To put these items on one line each, write: <verbatim> elementformat="$e <br />" </verbatim> ---+++ =titleformat= Attribute of =FORMELEMENT=. The default =titleformat= is <verbatim> $t <br /> </verbatim> To display the title in bold, write: <verbatim> titleformat=" *$t* <br />" </verbatim> #DateFormats ---+++ Date Formats Attribute of =FORMELEMENT= when =type="date"= is used. Possible format specifiers: <verbatim> %a - abbreviated weekday name %A - full weekday name %b - abbreviated month name %B - full month name %C - century number %d - the day of the month ( 00 .. 31 ) %e - the day of the month ( 0 .. 31 ) %H - hour ( 00 .. 23 ) %I - hour ( 01 .. 12 ) %j - day of the year ( 000 .. 366 ) %k - hour ( 0 .. 23 ) %l - hour ( 1 .. 12 ) %m - month ( 01 .. 12 ) %M - minute ( 00 .. 59 ) %n - a newline character %p - "PM" or "AM" %P - "pm" or "am" %S - second ( 00 .. 59 ) %s - number of seconds since Epoch (since Jan 01 1970 00:00:00 UTC) %t - a tab character %U, %W, %V - the week number The week 01 is the week that has the Thursday in the current year, which is equivalent to the week that contains the fourth day of January. Weeks start on Monday. %u - the day of the week ( 1 .. 7, 1 = MON ) %w - the day of the week ( 0 .. 6, 0 = SUN ) %y - year without the century ( 00 .. 99 ) %Y - year including the century ( ex. 1979 ) %% - a literal % character </verbatim> For example, to get the date formatted as "2009-01-31", specify: =dateformat="%Y-%m-%d"=. ---++ Form processing A !FormPlugin form is first processed before it is sent to its action target. Processing is done in 2 steps: 1 Substitution of field references. 1 Validation <div class="twikiImage"><img src="%ATTACHURLPATH%/form_on_submit_diagram.png" alt="" width='804' height='502' /></div> ---+++ Substitution of field references This allows to use entered field values as variables. For example: * A form element has the name "To" * Another form element (for instance a hidden field) has the default value "email response to $To" * When the form is submitted, =$To= is substituted for the form element value with that name * The form is passed along An example form that uses substitution: <verbatim> %STARTFORM{ name="mail" action="view" topic="%WEB%.%TOPIC%" method="POST" }% %FORMELEMENT{ type="text" name="To" }% %FORMELEMENT{ type="hidden" name="Subject" value="email to $To" mandatory="on" }% %FORMELEMENT{ type="submit" buttonlabel="Submit" }% %ENDFORM% Subject is: %URLPARAM{"Subject"}% </verbatim> ---+++ Form validation * Form elements can be checked on input that is nonempty, string, int, float or email * If a validation error occurs, the form is displayed with error feedback See =FORMELEMENT:validate= for usage instructions. %BR% Use =%<nop>FORMSTATUS{}%= to retrieve the status of the form; see [[#FormStatus][FORMSTATUS]]. ---++ Examples See [[Sandbox.FormPluginExamples]] #PluginSettings ---++ Plugin Settings Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<nop><plugin>_<setting>%==, i.e. ==%<nop>CACHECONTENTPLUGIN_SHORTDESCRIPTION%== * One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic: * Set SHORTDESCRIPTION = Lets you create simple and advanced web forms * Debug plugin: (See output in =data/debug.txt=) * Set DEBUG = 0 #PluginTest ---++ Plugin Tests * This plugin is %IF{"context FormPluginEnabled" then='%GREEN%enabled%ENDCOLOR%' else ='%RED%not enabled%ENDCOLOR%'}%. ---++ CSS classes | *Class name* | *Note* | | =formPluginNotification= | Used for validation error feedback | | =fieldset.formPluginGroup= | To group checkboxes and radio buttons | | =fieldset.formPluginGroupWithHint= | A group with an input hint - shows a border at the right | | =formPluginTitle= | Element title | | =formPluginError= | State that causes input fields to have a red border and titles to be bold red | | =formPluginHint= | Input hint | | =formPluginMandatory= | Mandatory indication (asterisk) | ---++ Installation %X% __Attention:__ This plugin version depends on the new TWiki:Plugins.DatePickerPlugin; the !JSCalendarContrib is no longer needed by this plugin and must be upgraded or uninstalled. %TWISTY{ mode="div" showlink="Show details %ICONURL{toggleopen}% " hidelink="Hide details %ICONURL{toggleclose}% " }% __Note:__ You do not need to install anything on the browser to use this extension. The following instructions are for the administrator who installs the extension on the TWiki server. * For an __automated installation__, run the [[%SCRIPTURL{configure}%][configure]] script and follow "Find More Extensions" in the in the __Extensions__ section. * See the [[http://twiki.org/cgi-bin/view/Plugins/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information. * Or, follow these __manual installation__ steps: * Download the ZIP file from the extension home on twiki.org (see below). * Unzip ==%TOPIC%.zip== in your twiki installation directory. * Set the ownership of the extracted directories and files to the webserver user. * Install the dependencies (if any). * Plugin __configuration and testing__: * Run the [[%SCRIPTURL{configure}%][configure]] script and enable the plugin in the __Plugins__ section. * Configure additional plugin settings in the __Extensions__ section if needed. * Test if the installation was successful using the examples provided. %ENDTWISTY% ---++ Plugin Info %TABLE{ tablewidth="100%" columnwidths="170," }% | Plugin Authors: | Arthur Clemens, Sven Dowideit, Eugen Mayer | | Other authors: | =Validate.pm=, originally =CGI::Validate= by Zenin <zenin@archive.rhps.org> aka Byron Brummer <byron@omix.com>. Copyright (c) 1997,1998 OMIX, Inc. All rights reserved. Use is granted under the same terms of Perl. | | Copyright: | © 2007-2010 Arthur Clemens, Sven Dowideit, [[TWiki:Main.EugenMayer][Eugen Mayer]]; <br /> © 2005-2013 TWiki:TWiki.TWikiContributor | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Plugin Version: | 2013-05-03 | %TWISTY{ mode="div" showlink="Show Change History %ICONURL{toggleopen}%" hidelink="Hide Change History %ICONURL{toggleclose}%" }% %TABLE{ tablewidth="100%" columnwidths="170," }% | 2013-05-03: | TWikibug:Item7251: Add Twisties to change history and installation section; fix TOC doc issue -- TWiki:Main.PeterThoeny | | 2013-05-03: | TWikibug:Item7251: FormPlugin doesn't work if there's a %<nop>TOC{%TOPIC%}% variable -- TWiki:Main.YaojunFei | | 2012-12-16: | TWikibug:Item7077: Make !FormPlugin dependent on DatePickerPlugin instead of deprecated !JSCalendarContrib -- TWiki:Main.PeterThoeny | | 2010-08-28: | TWikibug:Item6530 - doc improvements | | 31 May 2010 | 1.6.2 Fixed field reference substitution when saving a topic; improved CSS in error messages. | | 26 May 2010 | 1.6.1 Replaced =getRequestObject= with =getCgiQuery= | | 26 May 2010 | 1.6 Arthur Clemens: %BR%\ Bug fixes: \ %BB% Fixed pre-selecting multiple items in multi-select form elements. \ %BB% All TWiki scripts are now allowed in =action=. \ %BB% Fixed redirecting a topic and passing data in GET instead of POST (added =passthrough= parameter). %BR%%BR%\ More: %BR%\ Complete unit testing. %BR% \ Messages are now set in template =formplugin.tmpl=, making them easier to change. %BR% \ Improved documentation. | | 24 Aug 2009 | 1.5 Arthur Clemens: %BR%\ Bug fixes: \ %BB% Fixed checked value of radio button - sometimes did not get checked \ %BB% Fixed bug 0 value ignored \ %BB% Improved formatting for forms inside tables %BR% \ %BR% \ New features: \ %BB% In line of TWiki security policy, make POST the default submit method \ %BB% Added support for REST calls: set the action to =rest= and set =restaction= \ %BB% Added format parameter =$a= to set the location of the form element anchor link, useful for table layouts \ %BB% Changed param =allowredirects= to =noredirect= \ %BB% Pure text format =textonly=, no input element \ %BB% Added warning if required data is not passed for =STARTFORM= or =FORMELEMENT=. | | 16 Mar 2009 | 1.4.6 Eugen Mayer: Added new option for STARTFORM, which allows to control the redirects ( =allowredirects= ). | | 29 Jan 2009 | 1.4.5 Moved javascript and css includes to template files to allow other js libs to be used. | | 23 Jan 2009 | 1.4.4 added =id= for forms | | 20 Jan 2009 | 1.4.2 added =tabindex= - Arthur Clemens | | 20 Jan 2009 | 1.4 added =sep=""=, =showerrors=""= and =%<nop>FORMERROR%= and fixes for TWiki v1.0.0 - TWiki:Main.SvenDowideit | | 07 Jan 2009 | 1.3 TWiki release. | | 08 Mar 2008 | 1.2 Added =condition=, =noformhtml= and =dateformat= attributes. | | 19 Oct 2007 | 1.1 Added =date= type. | | 09 Jun 2007 | 1.0.5 Added upload parameter; option to turn off form validation; custom javascript has been replaced by code in =pub/TWiki/<nop>JavascriptFiles/twikiForm.js=; added Flickr example. | | 27 May 2007 | 1.0.4 Update javascript calls to new =twikiForm.js=. | | 19 May 2007 | 1.0.3 Added element attributes: =focus=, =disabled=, =readonly=; Javascript parameters =beforeclick=, =onFocus=, =onBlur=, =onMouseOver=, =onMouseOut=, =onSelect=, =onChange=, =onClick=, =onKeyUp=; form parameter =onSubmit=. Fallback for form POSTs and TWiki versions earlier than 4.2: POST requests are converted to GET requests. | | 15 May 2007 | 1.0.2 Added form attribute =elementformat=; changed parameter names for consistency: =class= to =cssclass=, =elementformat= to =fieldformat=. | | 13 May 2007 | 1.0 First release. | %ENDTWISTY% %TABLE{ tablewidth="100%" columnwidths="170," }% | CPAN Dependencies: |=-=| | Other Dependencies: |=-=| | Perl Version: | 5.005 | | Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% | | Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | | Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal | __Related Topics:__ %SYSTEMWEB%.TWikiPreferences, %USERSWEB%.TWikiPreferences, [[%SYSTEMWEB%.TWikiPlugins][Plugins]]
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
:
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r0 - 2013-05-04
-
TWikiContributor
TWiki
Log In
TWiki Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
User Reference
ATasteOfTWiki
TextFormattingRules
TWikiVariables
FormattedSearch
QuerySearch
TWikiDocGraphics
TWikiSkinBrowser
InstalledPlugins
Admin Maintenance
Reference Manual
AdminToolsCategory
InterWikis
ManagingWebs
TWikiSiteTools
TWikiPreferences
WebPreferences
Categories
Admin Documentation
Admin Tools
Developer Doc
User Documentation
User Tools
Webs
External
Main
Sandbox
TWiki
Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding ARC TWiki?
Send feedback
Note:
Please contribute updates to this topic on TWiki.org at
TWiki:TWiki.FormPlugin
.