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.
( new since v2.2.10 ) The message will also be parsed to check for square bracket form attribute names and replace them with their values.
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).
permissions
Overrule user permission on page edit or page create
Since version 2.1.12
FlexForm will check the users permission to edit or create a page. If a user is not allowed to create a page and the user submits a FlexForm that should create a page, a message will show the user has not the correct rights. ( The Wiki admin sets those rights ). Sometimes you do not want to give users ( or user groups ) edit or create rights, but you do want them to be able to e.g. create a new page using a FlexForm. You can then use the permissions argument. The value can be "can-edit", "can-create" or both "can-edit;can-create". The user will then be given the edit or create right using this FlexForm only.
Note that the user will also need to be able to view the Special:FlexForm page to be able to submit forms, so this may need to be configured separately. For example if you want to allow anonymous users that are not logged in to use a form while normally they are not allowed to view pages in the wiki, you could add the special page to the $wgWhitelistRead setting.
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
recaptcha-action ( since v.2.2.11 )
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
Since version 2.2.11 FlexForm supports ReCaptcha version 3, ReCaptcha Enterprise and ReCaptcha V2 (I'm not a robot). We have renamed the form argument recaptcha-v3-action to recaptcha--action, but we still support the previous argument for backwards compatibility.
We have also changed the configuration settings to :
$wgFlexFormConfig['rc_use'] = "enterprise"; // Defaults to v3. Can be v2, v3 and enterprise
$wgFlexFormConfig['rc_site_key'] = ""; // for v2 and v3
$wgFlexFormConfig['rc_secret_key'] = ""; // for v2 and v3
$wgFlexFormConfig['rce_project'] = ""; // for enterprise
$wgFlexFormConfig['rce_site_key'] = ""; // for enterprise
$wgFlexFormConfig['rce_api_key'] = ""; // for enterprise
Note: reCAPTCHA v3 will not work when submitting the form through AJAX (mwidentifier="ajax")
Note: Please read the Google reCaptcha documentation on how to get your site key and secret key ( for reCaptcha v2 and v3 ), and read the reCaptcha Enterprise documentation to set and retrieve the Project, Site key and Api keys
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>
json
FlexForm accepts a certain form of JSON Schema to render a Form. See Form options/JSON for more information an on how to utilize this.
json-type
This argument is used together with the json argument. See Form options/JSON for more information an on how to utilize this.
no_disable_on_submit
When a form is submitted, the submit button will be set to disabled and a spinner is shown. To disable this behavior, you can add the no_disable_on_submit argument.
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>