Manual:Extension/Forms/5.1.8: Difference between revisions

No edit summary
Tag: 2017 source edit
No edit summary
 
(One intermediate revision by the same user not shown)
Line 64: Line 64:


==Alternative Target: Template==
==Alternative Target: Template==
Instead of creating a standard wiki page or sending the form content via E-Mail, a Template can be used as the target for a form. In this case, the submitted form data is used to create a new wiki page based on an existing template structure, and form values are inserted into the template placeholders.  
Instead of creating a standard wiki page or sending the form content via E-Mail, a [[Manual:Templates|Template]] can be used as the target for a form. In this case, the submitted form data is used to create a new wiki page based on an existing template structure, and form values are inserted into the template placeholders.  
*'''Prerequisites''': Before a Template target can be used, a corresponding template page must already exist in the wiki. The template serves as the structural basis for the generated page. Form fields are mapped to placeholders defined in the template.  
*'''Prerequisites''': Before a Template target can be used, a corresponding template page must already exist in the wiki. The template serves as the structural basis for the generated page. Form fields are mapped to placeholders defined in the template.  
 
[[File:Manual:Template Target.jpg|alt=selecting Template as target for forms|center|thumb|550x550px|Template Target]]
*'''Target type''': Template
*'''Target type''': Template
*'''Template''': Name of the existing template used for page generation
*'''Template''': Name of the existing template used for page generation
*'''Predefined title''': optional default title for the newly created page or to predefine a page path (e.g., to create all generated pages as subpages under a specific parent page) <br>
*'''Predefined title''': optional default title for the newly created page or to predefine a page path (e.g., to create all generated pages as subpages under a specific parent page) <br>
<br>
<br>​It is recommended to use identical or clearly related naming for the form and the template to improve maintainability and make configuration dependencies easier to identify. This is typically used to generate standardized, human-readable wiki pages, while JSON-based targets are more commonly used when the output is intended for structured data processing.
It is recommended to use identical or clearly related naming for the form and the template to improve maintainability and make configuration dependencies easier to identify. This is typically used to generate standardized, human-readable wiki pages, while JSON-based targets are more commonly used when the output is intended for structured data processing.


==Adjust the styling==
==Adjust the styling==

Latest revision as of 14:39, 1 June 2026


The Forms extension allows formatting a wiki page or a user dialog as a form. It is also used in conjunction with the Workflows extension where it provides input forms for workflow data.

Introduction

To create a checklist as a form, for example, the following steps are necessary:

  1. Create the checklist form definition.
  2. Create checklist instances directly from the form definition page.


As an example, we are creating the first fields for an event where food-related hygiene information has to be tracked.

Event checklist example
Event checklist example

Create a checklist form

  1. Create the page Checklist Event Hygiene.form.
    Create-page dialog
    Creating a new form
    This opens the Form editor.
    elements of the form editor dialog
    Form editor
  2. Add a form section:
    1. Select the Section label element under Form Elements > Other (see screenshot annotation 2) and, holding down the left mouse button, drag it into the interactive form editor field below.
    2. Click anywhere in the Section label line. The field inspector opens.
    3. Enter the Name. This is saved as a field ID in the database and should therefore not contain any special characters.
    4. Enter the Title for the section label. This is displayed as the visible label for the text field.
      Section label element inspector
      Adding the first section header
  3. Create the form fields for the Event section. Here we add a text box as an example.
    1. Drag the Text element from Form elements > Inputs under the section heading.
    2. Click anywhere in the text field line. The field inspector opens.
    3. Enter the Name. This is used as the database ID for this field and should therefore not contain any special characters.
    4. Enter the Label. This is displayed as the visible label for the text field.
    5. Add more form elements.
  4. Click Save. The form is now available in the main namespace as EventChecklistHygiene.form.
    Saved form
    Saved form

To continue editing the form, switch to page edit mode (1).

Add more form elements

Now you can add more fields: View all form elements that you can add to your forms.

Create a checklist instance

To create a checklist from the form:

  1. Enter an event name
  2. Fill out the form fields.
  3. Click Submit.The checklist is now saved in the wiki and can be edited further.

Alternative Target: E-mail

Instead of creating a wiki page when the form is saved, you can send the form content to an E-Mail account. (Note: The E-Mail recipient has to be configured on the server by a server admin to be available to forms):

Email target
Email target
  • Target type: Email
  • Recipient: Possible recipients must have been configured on the server for security reasons. Example:
 $wgFormsTargetEMailRecipients = [

'Marketing' => "marketing@example.com",

'Administration' => 'WikiSysop'

];
  • Subject: Existing form fields can be used as variables here. The value is taken from the form.
  • Content: As in the subject, existing form fields can also be used as variables here. The value is taken from the form.


Localization messages in combination with form fields can also be used as subject or email body:

{{int:Mailsubject| {{{name}}}|{{{surname}}} }}


Alternative Target: Template

Instead of creating a standard wiki page or sending the form content via E-Mail, a Template can be used as the target for a form. In this case, the submitted form data is used to create a new wiki page based on an existing template structure, and form values are inserted into the template placeholders.

  • Prerequisites: Before a Template target can be used, a corresponding template page must already exist in the wiki. The template serves as the structural basis for the generated page. Form fields are mapped to placeholders defined in the template.
selecting Template as target for forms
Template Target
  • Target type: Template
  • Template: Name of the existing template used for page generation
  • Predefined title: optional default title for the newly created page or to predefine a page path (e.g., to create all generated pages as subpages under a specific parent page)


​It is recommended to use identical or clearly related naming for the form and the template to improve maintainability and make configuration dependencies easier to identify. This is typically used to generate standardized, human-readable wiki pages, while JSON-based targets are more commonly used when the output is intended for structured data processing.

Adjust the styling

Common.css

To style individual elements in the form, go to the styling tab in the options dialog. There, you can enter a css class name. The styling is then defined on the MediaWiki:Common.css page (admin rights are required).

To style the section heading:

  1. Open the styling tab in the options menu of the Event heading field.
  2. Add a new CSS class and enter a selector name (CSS Classes field), e.g. frm-sectionhd.
    Add a css class
    Add a css class
  3. Paste the following style declarations into the MediaWiki:Common.css page, e.g.:
    .frm-sectionhd {
        border-bottom: 1px solid #a6a6a7;  
        background:#f1f3f9; 
        padding:6px;
        margin:30px 0;
    }
    
    Section label with customized styling
    Section label with customized styling

If you do not have permission to view this page, you can enter style information directly for each element in the form via inline styling.

Inline styling

Without access to MediaWiki:Common.css, the style information can be entered directly in the form. However, with many recurring style declarations this is not efficient in contrast to the definition of CSS classes in MediaWiki:Common.css.

As an example, let's apply the previous section heading example directly as inline styling. To do this, open the options menu of the ech-event form element again. Enter the following statement in the Styling field and save the change:

border-bottom: 1px solid #a6a6a7;  background:#f1f3f9; padding:6px;margin:30px 0;
Inline styling of a form element
Inline styling of a form element



PDF exclude - start

To submit feedback about this documentation, visit our community forum.

PDF exclude - end