Extension:AutoFillFormField
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
AutoFillFormField Release status: unmaintained |
|
---|---|
Implementation | Parser function |
Description | Allows to automatically fill form input fields based on the (live) input of other fields |
Author(s) | Simon Heimler (Fannontalk) |
Latest version | 0.2.0 (April 2015) |
MediaWiki | 1.19+ |
PHP | 5.2+ |
Database changes | No |
License | MIT License |
Download | GitHub: Note: README |
The AutoFillFormField extension allows to automatically fill form input fields provided by the Semantic Forms extension based on the (live) input of other fields.
RationaleEdit
In some situations, choosing the correct page name is difficult, since there are many possibilities how to do it. This leads to inconsistencies, duplicated pages etc. This extension is an attempt to solve this problem when using Semantic Forms in edit mode.
It allows to define a field that holds the final page URL, providing a pattern how to build it. This pattern can create references to other fields, whose in-put values will be incorporated while typing.
InstallationEdit
- Download and place the file(s) in a directory called
AutoFillFormField
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/AutoFillFormField/AutoFillFormField.php";
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Instead of downloading the tarball you may also check this extension out via Git:
git clone https://github.com/Fannon/AutoFillFormField.git
UsageEdit
AutoFillFormField is triggered by applying certain CSS classes to fields in your Semantic Form.
Target FieldEdit
First you have to define the target field by applying the AutoFillFormFieldTarget
class to it. The field also needs to declare how the URL / name is built. This is done by adding a second class starting with URL:
followed by a string that declares how the field value needs to be built.
This string supports variables and substitutions. Variables are encapsulated in ? signs, like ?variable?
.
Currently the following substitutions are supported:
___
toFULLPAGENAME
will be substituted by the current full pagename.
Examples:
|class=AutoFillFormFieldTarget URL:?strasse?,___?plz?___?ort?
|class=AutoFillFormFieldTarget URL:FULLPAGENAME/?ip?
Source FieldsEdit
A source field is defined by adding the class AutoFillFormFieldSource and the variablename prefixed by source_
. Example: source_country
.
Every field that is referenced by a ?variable? needs a corresponding source_target.
Complete ExampleEdit
Semantic Form MarkupEdit
The important parts are marked in bold.
{{{for template|HeimarbeitsplatzAdresse|heimarbeitsplatz|label=heimarbeitsplatz|multiple|minimum instances=0}}} {| class="formtable" ! Heimarbeitsplatz: | {{{field|heimarbeitsplatz|size=none|class=AutoFillFormFieldTarget URL:?strasse?,___?plz?___?ort?|input type=text|list|delimiter=;|default=}}} |- ! Straße: | {{{field|strasse|size=none|class=AutoFillFormFieldSource source_strasse|input type=text|mandatory}}} |- ! Postleitzahl: | {{{field|plz|size=none|class=AutoFillFormFieldSource source_plz|input type=text|mandatory}}} |- ! Ort: | {{{field|ort|size=none|class=AutoFillFormFieldSource source_ort|input type=text|mandatory}}} |- ! Land: | {{{field|land|size=none|class=AutoFillFormFieldSource source_land|input type=dropdown|mandatory|default=DE|values from namespace=Land|existing values only}}} |- |} {{{end template}}}
ResultEdit
This is how the code above will look look / behave: