Name

_form

Type

_form

Synopsis

Various FlexForm options

Description

Parameters you can add to the _form tag.

Parameters

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


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 interval, on change or both.

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: WSForm will look for all elements that have a class name starting with "tinymce", as suggested by TinyMCE.


When using auto or oninterval 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.

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


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>

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 you 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

ws-page-props