(Imported by PageSync)
Tag: wsps-content-edit-tag
(27 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Installation ==
+
FlexForm is installed using [https://www.mediawiki.org/wiki/Composer/For_extensions Composer]:
Grab in instance from https://github.com/WikibaseSolutions/FlexForm.
 
  
Create a "'''FlexForm'''" folder in your Wiki extensions folder and extract the files there.
+
<syntaxhighlight lang="php">
 +
composer require open-csp/flex-form
 +
</syntaxhighlight>
 +
 
 +
You can install FlexForm from [https://github.com/Open-CSP/FlexForm github] by installing it in extensions/FlexForm. You do have to run composer --update inside that folder after installation to get all dependencies.  
  
 
==== Setup ====
 
==== Setup ====
You can tweak '''FlexForm''' to an extent in your Localsettings.php<syntaxhighlight lang="php">
+
You can tweak '''FlexForm''' to an extent in your <code>LocalSettings.php</code> file:
$wgFlexFormConfig['secure'] = true; //( default is true ). Will render form that make no sense when inspected in the browser
+
 
 +
<syntaxhighlight lang="php">
 +
// Will render form that makes no sense when inspected in the browser.
 +
$wgFlexFormConfig['secure'] = true;
 +
 
 +
// A salt key for encryption. Used together with "secure" option. Must be set when using multiple instances of a wiki.
 +
$wgFlexFormConfig['sec_key'] = "";
 +
 
 +
// Interval time in ms, defaults to 3 minutes (180000 ms). Form is submitted on each interval regardless of changes.
 +
$wgFlexFormConfig['auto_save_interval'] = 30000;
 +
 
 +
// Time in ms, defaults to 3 seconds (3000 ms). Form is submitted after the specified time, timer starts when there is a change in the form. Timer resets if there is another change before the time has passed.
 +
$wgFlexFormConfig['auto_save_after_change'] = 3000;
 +
 
 +
// Text on the autosave button to toggle on.
 +
$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on';
 +
 
 +
// Text on the autosave button to toggle off.
 +
$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off';
  
$wgFlexFormConfig['sec_key'] = ""; // A salt key for encryption. Used together with "secure" option. Must be set when using multiple instances of a wiki
+
// Currently the only form.
 +
$wgFlexFormConfig['FlexFormDefaultTheme'] = "plain";
  
$wgFlexFormConfig['auto_save_interval'] = 30000; // Interval time in ms, defaults to 3 minutes (180000 ms). Form is submitted on each interval regardless of changes.
+
// reCaptcha site key.
 +
$wgFlexFormConfig['rc_site_key'] = "";
  
$wgFlexFormConfig['auto_save_after_change'] = 3000; // Time in ms, defaults to 3 seconds (3000 ms). Form is submitted after the specified time, timer starts when there is a change in the form. Timer resets if there is another change before the time has passed.
+
// reCaptcha secret key.
 +
$wgFlexFormConfig['rc_secret_key'] = "";
  
$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on'; // text on the autosave button to toggle on
+
// Where to store images temporarily that need to be format converted.
 +
$wgFlexFormConfig['file_temp_path'] = "";
  
$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off'; // text on the autosave button to toggle off
+
// Defaults to false. Set to yes if FlexForm is allowed to create new users.
 +
$wgFlexFormConfig['can_create_user'] = "";
  
$wgFlexFormConfig['FlexFormDefaultTheme'] = "plain"; // Currently the only form
+
// Defaults to false. Will filter all parser arguments to plain text, except value parameters. Will also disallow onClick and onFocus parameter. This feature will most likely be removed in future updates.
 +
$wgFlexFormConfig['filter_input_tags'] = false;
  
$wgFlexFormConfig['rc_site_key'] = ""; // reCaptcha site key
+
// Defaults to what is described by the loadscript form argument. When you change it do a different folder, then loadScript argument will be looking in this folder for its JavaScript file to load with the Form.
 +
$wgFlexFormConfig['loadScriptPath'] = "";
  
$wgFlexFormConfig['rc_secret_key'] = ""; // reCaptcha secret key
+
// Defaults to sysop. Only a user in the allowedGroups is able to edit pages with a FlexForm in the source.
 +
$wgFlexFormConfig['allowedGroups'] = ["sysop","moderator"];
  
$wgFlexFormConfig['file_temp_path'] = ""; // Where to store images temporarily that need to be format converted
+
// Defaults to true. When a user in the allowedGroups creates a form it will become valid and will be rendered. Someone not in the allowedGroups can create a form and save it, but it will never be rendered until a user from the allowedGroups will edit and re-save the page. Only then will a form become valid. The message "FORM CANNOT BE RENDERED, NOT VALIDATED" will be shown instead of the form when it is invalid or depending on the next setting an image stating it cannot be rendered.
 +
$wgFlexFormConfig['renderonlyapprovedforms'] = true;
  
$wgFlexFormConfig['can_create_user'] = ""; // Defaults to false. Set to yes if FlexForm is allowed to create new users
+
// When a form is invalid, an invalid image will be rendered instead of the form. Set to true to render i18n invalid message.
 +
$wgFlexFormConfig['renderi18nErrorInsteadofImageForApprovedForms'] = false;
  
$wgFlexFormConfig['filter_input_tags'] = false; // Defaults to false. Will filter all parser arguments to plain text, except value parameters. Will also disallow onClick and onFocus parameter. This feature will most likely be removed in future updates.
+
// Defaults to false. This differs from FlexForm before 2.0. FlexForm will now honor the UserCan functions in MediaWiki. If a form edits or creates a page a user has no rights to, the form will fail.
 +
$wgFlexFormConfig['userscaneditallpages'] = false;
  
$wgFlexFormConfig['CreateAndEditForms']['allowedGroups'] = ["sysop","moderator"]; // Defaults to sysop. Only a user in the allowedGroups is able to edit pages with a FlexForm in the source.
+
// Defaults to true. If a user is not in the allowedGroups then hide edit and editsource menu items for any page containing a FlexForm form.
 +
$wgFlexFormConfig['hideEdit'] = true;
  
$wgFlexFormConfig['CreateAndEditForms']['renderonlyapprovedforms'] = true; // Defaults to true. When a user in the allowedGroups creates a form it will become valid and will be rendered. Someone not in the allowedGroups can create a form and save it, but it will never be rendered until a user from the allowedGroups will edit and re-save the page. Only then will a form become valid. The message "FORM CANNOT BE RENDERED, NOT VALIDATED" will be shown instead of the form when it is invalid.
+
// Defaults to false. Will turn titles given to wscreate into url friendly slugs. Creating only latin character and converting spaces and special characters.
 +
$wgFlexFormConfig['create-seo-titles'] = true;
  
$wgFlexFormConfig['CreateAndEditForms']['userscaneditallpages'] = false; // Defaults to false. This differs from FlexForm before 2.0. FlexForm will now honor the UserCan functions in MediaWiki. If a form edits or creates a page a user has no rights to, the form will fail.
+
// If you have a custom/different version of Pandoc than the one set by your hosting provider, you can add its local path here and FlexForm will use it, instead of the one set by environment variables
 +
$wgFlexFormConfig['pandoc-install-path'] = $IP . '/bin/pandoc'; // This will look for Pandoc executable in the root/bin of your MediaWiki instalment
  
$wgFlexFormConfig['CreateAndEditForms']['hideEdit'] = true; // Defaults to true. If a user is not in the allowedGroups then hide edit and editsource menu items for any page containing a FlexForm form.
+
// FlexForm will by default always do an extra null edit on a save or an edit. This is mainly due to SMW. Not always this is necessary, so with this option you can turn it off. ( resulting in less handling time )
 +
$wgFlexFormConfig['forceNullEdit'] = true; // Default to true for backwards compatibility
  
$wgFlexFormConfig['create-seo-titles'] = true; // Defaults to false. Will turn titles given to wscreate into url friendly slugs. Creating only latin character and converting spaces and special characters.
+
// When sending email, should we use separate smtp?
 +
$wgFlexFormConfig['use_smtp'] = false;
 +
 
 +
$wgFlexFormConfig['smtp_host'] = "";
 +
 
 +
$wgFlexFormConfig['smtp_authentication'] = true;
 +
 
 +
$wgFlexFormConfig['smtp_username'] = "";
 +
 
 +
$wgFlexFormConfig['smtp_password'] = "";
 +
 
 +
$wgFlexFormConfig['smtp_secure'] = "TLS";
 +
 
 +
$wgFlexFormConfig['smtp_port'] = "587";
  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Finally ====
+
==== Installation ====
Add the following line at the end of your LocalSettings.php to enable the extension :<syntaxhighlight lang="php">
+
* Add the following line at the end of your <code>LocalSettings.php</code> to enable the extension:
 +
 
 +
<syntaxhighlight lang="php">
 
wfLoadExtension( 'FlexForm' );
 
wfLoadExtension( 'FlexForm' );
 
</syntaxhighlight>
 
</syntaxhighlight>
  
It is also a good idea to turn off parsing cache when using dynamic forms like FlexForm.
+
* It is also recommended to turn off the parser cache when using FlexForm:
 +
 
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
 
$wgParserCacheType = CACHE_NONE;
 
$wgParserCacheType = CACHE_NONE;
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
* Run the [https://www.mediawiki.org/wiki/Manual:Update.php update script] which will automatically create the necessary database tables that this extension needs.
 +
* Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
 +
 +
==== Migrate from version 1.x to 2.0 ====
 +
* Please notice the changes in the config settings.
 +
* Do not forget to run update.php.
 +
* Also, by default, the setting '''renderonlyapprovedforms''' will be '''true'''. Meaning that once you install FlexForm v2.0 all your existing FlexForm forms in your wiki will be shown as unvalidated. Visit [[DevOps:Doc/FlexForm/2.0/Validated Forms|Validated Forms]] to read how to solve this easily.
  
 
==== Notification/Messages ====
 
==== Notification/Messages ====
'''FlexForm''' has a notification system build in. This is used to show possible errors or success / custom messages.
+
FlexForm has a notification system built in. This is used to show possible errors or success/custom messages.  
To enable this.. add to your header page :<syntaxhighlight lang="php">
+
 
<_form showmessages />
+
'''As of version 2.2.2 this is a default feature''' and <nowiki><form showmessage /></nowiki> is deprecated.
</syntaxhighlight>
 
ws-class-props
Line 1: Line 1:
{{Doc properties
+
{{Csp class properties
|Subject version=2.0
+
|Subject version=2.0,2.1
 
|Doc subject=DevOps:Doc/FlexForm
 
|Doc subject=DevOps:Doc/FlexForm
|Doc sort order=1,005
+
|Doc sort order=1.005
 
|Doc target group=Administrator
 
|Doc target group=Administrator
 +
|Doc synopsis=How to install FlexForm
 +
|Doc parent=
 
}}
 
}}
ws-seo
Line 1: Line 1:
 
+
{{SEO
 +
|Title=Installation of FlexForm
 +
|Keywords=mediawiki,install,flexform
 +
|Description=How to install the MediaWiki extension FlexForm
 +
|Image=FlexForm logo.png
 +
|Section=Documentation/FlexForm
 +
}}

Revision as of 10:34, 15 July 2025

FlexForm is installed using Composer:

composer require open-csp/flex-form

You can install FlexForm from github by installing it in extensions/FlexForm. You do have to run composer --update inside that folder after installation to get all dependencies.

Setup

You can tweak FlexForm to an extent in your LocalSettings.php file:

// Will render form that makes no sense when inspected in the browser.
$wgFlexFormConfig['secure'] = true;

// A salt key for encryption. Used together with "secure" option. Must be set when using multiple instances of a wiki.
$wgFlexFormConfig['sec_key'] = "";

// Interval time in ms, defaults to 3 minutes (180000 ms). Form is submitted on each interval regardless of changes.
$wgFlexFormConfig['auto_save_interval'] = 30000;

// Time in ms, defaults to 3 seconds (3000 ms). Form is submitted after the specified time, timer starts when there is a change in the form. Timer resets if there is another change before the time has passed.
$wgFlexFormConfig['auto_save_after_change'] = 3000;

// Text on the autosave button to toggle on.
$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on';

// Text on the autosave button to toggle off.
$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off';

// Currently the only form.
$wgFlexFormConfig['FlexFormDefaultTheme'] = "plain";

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

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

// Where to store images temporarily that need to be format converted.
$wgFlexFormConfig['file_temp_path'] = "";

// Defaults to false. Set to yes if FlexForm is allowed to create new users.
$wgFlexFormConfig['can_create_user'] = "";

// Defaults to false. Will filter all parser arguments to plain text, except value parameters. Will also disallow onClick and onFocus parameter. This feature will most likely be removed in future updates.
$wgFlexFormConfig['filter_input_tags'] = false;

// Defaults to what is described by the loadscript form argument. When you change it do a different folder, then loadScript argument will be looking in this folder for its JavaScript file to load with the Form.
$wgFlexFormConfig['loadScriptPath'] = "";

// Defaults to sysop. Only a user in the allowedGroups is able to edit pages with a FlexForm in the source.
$wgFlexFormConfig['allowedGroups'] = ["sysop","moderator"];

// Defaults to true. When a user in the allowedGroups creates a form it will become valid and will be rendered. Someone not in the allowedGroups can create a form and save it, but it will never be rendered until a user from the allowedGroups will edit and re-save the page. Only then will a form become valid. The message "FORM CANNOT BE RENDERED, NOT VALIDATED" will be shown instead of the form when it is invalid or depending on the next setting an image stating it cannot be rendered.
$wgFlexFormConfig['renderonlyapprovedforms'] = true;

// When a form is invalid, an invalid image will be rendered instead of the form. Set to true to render i18n invalid message.
$wgFlexFormConfig['renderi18nErrorInsteadofImageForApprovedForms'] = false;

// Defaults to false. This differs from FlexForm before 2.0. FlexForm will now honor the UserCan functions in MediaWiki. If a form edits or creates a page a user has no rights to, the form will fail.
$wgFlexFormConfig['userscaneditallpages'] = false;

// Defaults to true. If a user is not in the allowedGroups then hide edit and editsource menu items for any page containing a FlexForm form.
$wgFlexFormConfig['hideEdit'] = true;

// Defaults to false. Will turn titles given to wscreate into url friendly slugs. Creating only latin character and converting spaces and special characters.
$wgFlexFormConfig['create-seo-titles'] = true;

// If you have a custom/different version of Pandoc than the one set by your hosting provider, you can add its local path here and FlexForm will use it, instead of the one set by environment variables
$wgFlexFormConfig['pandoc-install-path'] = $IP . '/bin/pandoc'; // This will look for Pandoc executable in the root/bin of your MediaWiki instalment

// FlexForm will by default always do an extra null edit on a save or an edit. This is mainly due to SMW. Not always this is necessary, so with this option you can turn it off. ( resulting in less handling time )
$wgFlexFormConfig['forceNullEdit'] = true; // Default to true for backwards compatibility

// When sending email, should we use separate smtp?
$wgFlexFormConfig['use_smtp'] = false;

$wgFlexFormConfig['smtp_host'] = "";

$wgFlexFormConfig['smtp_authentication'] = true;

$wgFlexFormConfig['smtp_username'] = "";

$wgFlexFormConfig['smtp_password'] = "";

$wgFlexFormConfig['smtp_secure'] = "TLS";

$wgFlexFormConfig['smtp_port'] = "587";

Installation

  • Add the following line at the end of your LocalSettings.php to enable the extension:
wfLoadExtension( 'FlexForm' );
  • It is also recommended to turn off the parser cache when using FlexForm:
$wgParserCacheType = CACHE_NONE;
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Migrate from version 1.x to 2.0

  • Please notice the changes in the config settings.
  • Do not forget to run update.php.
  • Also, by default, the setting renderonlyapprovedforms will be true. Meaning that once you install FlexForm v2.0 all your existing FlexForm forms in your wiki will be shown as unvalidated. Visit Validated Forms to read how to solve this easily.

Notification/Messages

FlexForm has a notification system built in. This is used to show possible errors or success/custom messages.

As of version 2.2.2 this is a default feature and <form showmessage /> is deprecated.