m (Text replacement - "|Subject version=1.0,1.1,2.0,2.1↵" to "|Subject version=1.0,1.1,2.0,2.1,2.5 ")
 
(11 intermediate revisions by 5 users not shown)
Line 12: Line 12:
 
'''target''' = Target page ( title or page id ) that needs to be edited
 
'''target''' = Target page ( title or page id ) that needs to be edited
  
'''template ''' = Name of the template on the target page that needs to be edited
+
'''template ''' = Name of the template on the target page that needs to be edited. If there are multiple instances of the same template, you can specify what instance FlexForm should use if you have a unique key and value in the specific instance. You define it by '''template="<name of template>|<name of argument>=<value of argument>"'''. E.g. '''template="Edit user|User id=55"'''
  
 
'''formfield''' = Name of the field in the template. Field in the form should have the same name
 
'''formfield''' = Name of the field in the template. Field in the form should have the same name
Line 25: Line 25:
 
<syntaxhighlight lang="html">
 
<syntaxhighlight lang="html">
 
<_edit target="pageid" template="template" formfield="formfield" />
 
<_edit target="pageid" template="template" formfield="formfield" />
 +
</syntaxhighlight>
 +
 +
Simple test with a complete form you can use to see if editing works: Copy the following code snippet to the source code of a page and save. You will see a text field that will edit the "Content" parameter within the "Test" template call. Note that Template:Test does not need to exist for this example to work.
 +
<syntaxhighlight lang="html">
 +
{{Test
 +
|Content=abc
 +
}}
 +
 +
<form>
 +
<_edit target="{{PAGEID}}" template="Test" formfield="Content" />
 +
<input type="text" name="Content" />
 +
<input type="submit"/>
 +
</form>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 30: Line 43:
  
 
* You can have multiple _edit's in a form all doing different tasks.
 
* You can have multiple _edit's in a form all doing different tasks.
* If you have more than 5 edits to one singe page in the wiki, consider [[DevOps:Doc/FlexForm/1.0/create]] to speed-up the process.
+
* If you have more than 5 edits to one single page in the wiki, consider [[DevOps:Doc/FlexForm/1.0/create]] to speed-up the process.
 
* If you omit value, then the value of the form will be used (so what a user has filled in).
 
* If you omit value, then the value of the form will be used (so what a user has filled in).
 
===Links===
 
===Links===
 
https://www.mediawiki.org/wiki/Multi-Content_Revisions
 
https://www.mediawiki.org/wiki/Multi-Content_Revisions
 +
 +
{{FlexForm/Create and edit comparison}}
ws-class-props
Line 1: Line 1:
 
+
{{Csp class properties
 +
|Doc subject=DevOps:Doc/FlexForm
 +
|Subject version=1.0,1.1,2.0,2.1,2.5
 +
|Doc parent=DevOps:Doc/FlexForm/create-or-edit-a-page
 +
|Doc sort order=205
 +
|Doc target group=User
 +
|Doc synopsis=Using a form to edit pages that have content with templates
 +
}}
ws-page-props
Line 1: Line 1:
{{Doc properties
+
 
|Doc subject=DevOps:Doc/FlexForm
 
|Subject version=1.0,1.1
 
|Doc parent=DevOps:Doc/FlexForm/create-or-edit-a-page
 
|Doc sort order=205
 
|Doc target group=User
 
}}
 

Latest revision as of 11:37, 21 August 2025

Name

_edit

Type

_edit

Synopsis

Using a form to edit pages that have content with templates.

Description

How to edit pages in the wiki with FlexForm

Parameters

_edit

target = Target page ( title or page id ) that needs to be edited

template = Name of the template on the target page that needs to be edited. If there are multiple instances of the same template, you can specify what instance FlexForm should use if you have a unique key and value in the specific instance. You define it by template="<name of template>|<name of argument>=<value of argument>". E.g. template="Edit user|User id=55"

formfield = Name of the field in the template. Field in the form should have the same name

usefield = [optional] If the field in the form differs from the template variable name, you can use "usefield" to let _edit know what other field from the form it should use

value = [optional] Don't read the value from the form field, but use this value explicitly

mwslot = [optional] Name of content slot to use

Example

<_edit target="pageid" template="template" formfield="formfield" />

Simple test with a complete form you can use to see if editing works: Copy the following code snippet to the source code of a page and save. You will see a text field that will edit the "Content" parameter within the "Test" template call. Note that Template:Test does not need to exist for this example to work.

{{Test
|Content=abc
}}

<form>
<_edit target="{{PAGEID}}" template="Test" formfield="Content" />
<input type="text" name="Content" />
<input type="submit"/>
</form>

Note

  • You can have multiple _edit's in a form all doing different tasks.
  • If you have more than 5 edits to one single page in the wiki, consider create to speed-up the process.
  • If you omit value, then the value of the form will be used (so what a user has filled in).

Links

https://www.mediawiki.org/wiki/Multi-Content_Revisions

The _create and _edit tags share a lot of functionality but they do not always share the same attribute names or their intended usage may differ slightly. By presenting these attributes side by side, the following table may help you on your way more quickly.
_create _edit comments
Can be used to create new pages
Can be used to edit existing pages
Cannot be used to edit a selection of fields on a page
Cannot be used to create new pages
Can be used to edit existing pages,
including select fields
mwwrite
page title, optionally a formula in conjunction with mwoption or mwleadingzero
target
page id or page title
specific to page creation:
  • mwleadingzero
  • mwoption
  • noseo
  • nooverwrite
x
mwfollow x If you know the name of the target page in advance, you can always set mwreturn in the form tag instead. mwfollow was specifically created for use cases where the title of the page to be created cannot be predicted.
mwfields
allows for multiple fields (comma-separated)
formfield
allows for single fields only
x usefield
mwslot mwslot
mwformat format wiki or json
mwtemplate template template name or JSON configuration
x value can be used to set the value explicitly, without reading it from a form field.