Name

form

Type

form

Synopsis

Various FlexForm options

Description

Parameters you can add to the _form tag.

Parameters

action

Action telling Flexform what this form is for

There are three options :

  • addToWiki : If no action is set, this is the default action. It will expect _create or _edit input telling it what to do with the form
  • get : Same as addToWiki, except now the page FlexForm is going to after submit will have all form input and values in the url of the page. Handy to e.g. forward to the Wiki Search page.
  • email: Same as addToWiki, except now FlexForm will also look for the email options inside a form

formtarget

Change the html post action to a custom one

In some rare cases you might want to create a FlexForm, but not have FlexForm handle the post data. In that case use formtarget="your url here" to tell html form where to go when someone submits the data.

See example 1

Note: Keep in mind that this option will completely ignore FlexForm on form submission. No pages will be created or edited.


messageonsuccess

Show a custom message when form is successfully posted

It's sometimes handy to show a custom message when a form has been successfully posted, especially when after a post you return to the same form page.

See example 2


attachmessageto

Where to show the message

By default, except for Ajax form submit, the default MediaWiki Message notifier is used to show your messageonsuccess or any of the other messages FlexForm might give (e.g. an error). Sometimes it can be handy to control where the notification pops-up, instead of the default right-top. You can use attachmessageto to attach the notification to an id of a certain HTML element. The notification will happen there. E.g. <form attachmessageto="#my-unique-id">


mwreturn

Redirect to this page after submitting the form

When a form is submitted FlexForm will return to the page the Form was submitted from. You can change it to go to another page ( like a thank-you page for example ) by setting mwreturn. mwreturn="Thank-you-page". Provide a URL (the localurl and fullurl magic words may come in handy).


no_disable_on_submit

= Change the default form disabled and spinner on submit

By default when someone presses the submit button to submit a form, FlexForm will show a spinner and disable the submit button, to make sure people do not press the submit button twice. When you add this argument to a form, you will disable this default behavior and FlexForm will not show a spinner and will not disable the submit button.



no_submit_on_return

Disable enter key for submitting a form

A HTML form usually gets submitted on pressing enter when there's like one text field. To disable that use the no_submit_on_return option. This will add some JavaScript to the form disabling form submission on typing an enter.

See example 3


recaptcha-v3-action

Use reCaptcha Version 3 on a flexform

Have FlexForm use Google reCAPTCHA v3 to prevent spamming in a form.

You need to add you recaptcha key and secret in the configuration.

$wgFlexFormConfig['rc_site_key']   = ""; // reCaptcha site key
$wgFlexFormConfig['rc_secret_key'] = ""; // reCaptcha secret key

Then you can use

recaptcha-v3-action="action name"

Where action name is the name of the action to describe the form. It's an extra security measurement. You can choose your own name e.g. : contactform

See example 4

Note: reCAPTCHA v3 will not work when submitting the form through AJAX (mwidentifier="ajax")


autosave

Auto save forms on interval, after change or both

FlexForm autosave function allows for saving the open form in the background while someone is writing in it.

This feature has 3 options:

Save a form in the background on oninterval, on onchange or onboth.
As of v1.1.28 onintervalafterchange has been added.

It support "normal" forms as well as a form with mwidentifier="ajax", meaning a form setup to be posted as an Ajax call. Also tested with TinyMCE ( tinymce extension ).

TinyMCE Note: FlexForm will look for all elements that have a class name starting with "tinymce", as suggested by TinyMCE.


When using onboth, oninterval or onintervalafterchange a button will be added to the top of the form showing autosave interval is on. Clicking the button will turn interval saving off. When you turn it off and autosave is set to auto, the after change will still autosave. onintervalafterchange will add this button after a change has been detected.

Config

The interval time and the after on change time can be set in the config file. When using interval or auto, the text for the button that appears above the form can be set in the config file.

To style the button to switch off and on the Interval saving classes are added to it in different states:

When on it will have the classes : btn btn-primary ws-interval-on

When off it will have the classes : btn btn ws-interval-off

Parameters

On form create tag add autosave as parameter. e.g.

This will set autosave to auto.

<form action="addToWiki" id="unique id per form" autosave=""></form>


Set autosave to interval only :

<form action="addToWiki" id="unique id per form" autosave="oninterval"></form>


Set autosave to change only :

<form action="addToWiki" id="unique id per form" autosave="onchange"></form>

Note: A form needs to have an unique identifier set by its id

Set autosave to interval after change only : This will set the interval saving after a change has been detected. So it is basically the same as oninterval, except it won't start if there are no changes yet.

<form action="addToWiki" id="unique id per form" autosave="onintervalafterchange"></form>

Set autosave to none to not have autosave. This can be useful for templates that contain forms, when they should only have autosave in specific situations.

<form action="addToWiki" id="test-autosave-form" autosave="{{#if:...|auto|none}}" >
<input type="text" />
<input type="submit" />
</form>

setwikicomment

Set the summary text shown in the recent changes and or contributions

This can be really handy to describe what form or action was responsible for the changes in the Wiki.

<form action="addToWiki" setwikicomment="Edit user preference form" >
   Your flexform elements here
</form>

loadscript

Tell FlexForm to load a specific JavaScript with a form

Sometimes it can be handy to load a JavaScript to work with a Form. For example for Validation or Realtime look-ups and you only need to load that JavaScript for a specific form, instead of having it always be loaded in e.g. common.js.

loadscript by default looks into the FlexForm/Modules/customJS/loadScripts extension folder to find the JavaScript you have entered as value for loadscript. If your JavaScript is called validateForms.js, then you copy that JavaScript into the default folder and add loadscript="validateForms" to the Form tag.


You can also specify a different default folder using the config setting : $wgFlexFormConfig['loadScriptPath'] = <path to your scripts>. See also Installation of FlexForm. By request, if the script cannot be found, the form will not be rendered and a message is shown, so there is always a visual check available.


extension

Have an extension do additional tasks with form values

You can create an extension for FlexForm that can do additonal tasks to a Form. See extension Docs for more information

<form action="addToWiki" extension="<name of your extension" >
   Your flexform elements here
</form>

Examples

Example 1 : formtarget

<form action="addToWiki" formtarget="https://example.com/handleform.php" >
   Your flexform elements here
</form>

Example 2 : messageonsuccess

<form action="addToWiki" messageonsuccess="Information posted, thanks!">
    Your flexform elements here
</form>

Example 3 : no_submit_on_return

<form action="addToWiki" no_submit_on_return>
    Your flexform elements here
</form>

Example 4 : reCaptcha v3

<form action="addToWiki"  recaptcha-v3-action="contactform">
    Your flexform elements here
</form>

Note

Links

https://developers.google.com/recaptcha/docs/v3