Line 1: | Line 1: | ||
+ | ===Name=== | ||
+ | _edit JSON content | ||
+ | ===Type=== | ||
+ | _edit | ||
+ | ===Synopsis=== | ||
+ | Using a form to edit pages that have content with JSON. | ||
+ | ===Description=== | ||
+ | How to edit JSON content pages in the wiki with FlexForm. | ||
+ | The edit function is very similar to editing template content, we will brake down the differences here. | ||
+ | |||
+ | ===Parameters=== | ||
+ | '''_edit''' | ||
+ | |||
+ | '''target''' = Target page ( title or page id ) that needs to be edited | ||
+ | |||
+ | '''mwformat''' = "json". Tell an edit that we are working with JSON | ||
+ | |||
+ | '''template ''' = This argument has been kept to keep editing a template wiki page and editing a JSON page similar to each other. | ||
+ | Name of the template differs from editing template content and now has two options : json and jsonk. | ||
+ | *json : When you create a JSON page with _create, every new named array will also get a unique id, called ffID. The following example tell FlexForm to find a certain ffID and then find a named value ( so the key ) called Title. FlexForm will then check if the submitted form has an input with the same name the "Title" and use it's value to add to the JSON. | ||
+ | |||
+ | Example JSON: | ||
+ | <syntaxhighlight lang="php"> | ||
+ | { | ||
+ | "Coats": { | ||
+ | "ffID": 1669192355, | ||
+ | "Title": "The Body protector", | ||
+ | "Type": "Bodywarmer", | ||
+ | "Color": [ | ||
+ | "blue", | ||
+ | "pink" | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | Example EDIT: | ||
+ | <syntaxhighlight lang="php"> | ||
+ | <_edit target="Json_test_result" format="json" template="json|ffID=1669192355" formfield="Title" /> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | '''formfield''' = Name of the field in the template. Field in the form should have the same name | ||
+ | |||
+ | '''value''' = [optional] Don't read the value from the form field, but use this value explicitly | ||
+ | |||
+ | '''mwslot''' = [optional] Name of content slot to use. Defaults to main content slot | ||
+ | |||
+ | ===Example=== | ||
+ | <syntaxhighlight lang="html"> | ||
+ | <_edit target="pageid" template="template" formfield="formfield" /> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===Note=== | ||
+ | |||
+ | * 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 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 |
Revision as of 11:54, 23 November 2022
Name
_edit JSON content
Type
_edit
Synopsis
Using a form to edit pages that have content with JSON.
Description
How to edit JSON content pages in the wiki with FlexForm.
The edit function is very similar to editing template content, we will brake down the differences here.
Parameters
_edit
target = Target page ( title or page id ) that needs to be edited
mwformat = "json". Tell an edit that we are working with JSON
template = This argument has been kept to keep editing a template wiki page and editing a JSON page similar to each other. Name of the template differs from editing template content and now has two options : json and jsonk.
- json : When you create a JSON page with _create, every new named array will also get a unique id, called ffID. The following example tell FlexForm to find a certain ffID and then find a named value ( so the key ) called Title. FlexForm will then check if the submitted form has an input with the same name the "Title" and use it's value to add to the JSON.
Example JSON:
{
"Coats": {
"ffID": 1669192355,
"Title": "The Body protector",
"Type": "Bodywarmer",
"Color": [
"blue",
"pink"
]
}
}
Example EDIT:
<_edit target="Json_test_result" format="json" template="json|ffID=1669192355" formfield="Title" />
formfield = Name of the field in the template. Field in the form should have the same name
value = [optional] Don't read the value from the form field, but use this value explicitly
mwslot = [optional] Name of content slot to use. Defaults to main content slot
Example
<_edit target="pageid" template="template" formfield="formfield" />
Note
- 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 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).