Form templates are authored as .moform XML files and loaded into the Mosaic database. Each template defines the questions (fields) that appear on a form, the validation rules that apply, the layout for screen and print views, and any pre-population from person records. Once loaded, a template can be assigned to workflow step activities so that workers complete the form as part of their casework.
β οΈ Important: Changes to form templates affect all future instances of forms created from that template. Test templates thoroughly before deploying to a live environment.
Template structure
Every .moform file has three required top-level sections:
Section | What it defines |
TemplateMetaData | The template's identity, its unique code, context (child / adult), version, and description. |
Model | The data model - all question definitions and lookup option lists. |
Views | The visual layout of how questions are arranged on screen and in print. |
Template metadata
The TemplateMetaData section identifies the template and controls versioning.
Field | Description |
TemplateUserCode | A unique code for this template across the system. |
Context | C for children's services, A for adult services. |
Title | The display title shown to workers. |
Description | A short description of the form's purpose. |
Version | The version number of this template definition. |
Category | The template category, for example FORM. |
FormGroupCode | A grouping code for organising related templates. |
Define questions
Questions are defined in the Model section. Each question represents a single field on the form.
Question attributes
Attribute | Description |
QuestionUserCode | A unique identifier for this question within the template. |
AnswerDatatype | The data type of the field (see field types below). |
QuestionText | The label displayed to the worker. |
Mandatory | True or False whether the field must be completed. |
Editable | True or False whether the worker can change the value. |
ValidationRule | The validation rule applied to the field (see validation rules below). |
DataSourceUri | Optional - a URI to pre-populate the field from person record data. |
QuestionLookupSet | The name of a lookup option list (for dropdown and radio button fields only). |
Field types
Each question must specify an answerDatatype to determine the type of field:
Data type | Description | Notes |
SHORT_TEXT | Single-line text | Maximum 4,000 characters |
LONG_TEXT | Multi-line text or rich text | Use with the RichText validation rule for formatted text |
DATE | Date value | Rendered as a date picker |
NUMBER | Numeric value | Range depends on the validation rule applied |
BOOLEAN | Yes/No checkbox | Rendered as a single checkbox |
LOOKUP | Selection from a list | Rendered as a dropdown or radio buttons depending on the view appearance |
IMAGE_URI | Image upload | Rendered as an image upload or drop zone |
Validation rules
Each question can reference a validation rule that controls the accepted format and range. The following rules are available:
Rule name | Data type | Description |
RichText | LONG_TEXT | HTML rich text field |
LONG_TEXT | LONG_TEXT | Plain multi-line text |
SHORT_TEXT | SHORT_TEXT | Single-line text, maximum 4,000 characters |
DATE | DATE | Date only |
DateTime | DATE | Date and time |
NUMBER | NUMBER | Decimal number with up to 25 total digits and 9 decimal places |
BOOLEAN | BOOLEAN | Checkbox |
LOOKUP | LOOKUP | Dropdown or radio button selection |
PositiveDecimal5d2 | NUMBER | Positive decimal, 0.01 to 999.99 |
NonNegativeShort | NUMBER | Non-negative whole number, maximum 4 digits |
Decimal11d2 | NUMBER | Decimal, up to Β±999,999,999.99 |
NonNegativeLong9Digits | NUMBER | Non-negative whole number, maximum 9 digits |
Long9Digit | NUMBER | Whole number (positive or negative), maximum 9 digits |
Verification | SHORT_TEXT | Verification detail field, maximum 4,000 characters |
ChronologyId | NUMBER | Internal reference to a chronology event |
IMAGE_URI | IMAGE_URI | Image URI |
π Note: Validation rules are referenced in the moform file using the **mo:** prefix, for example `validationRule="mo:RichText"`.
Define lookup option lists
For LOOKUP type questions, you need to define a QuestionLookupSet containing the available options.
β
Each lookup set has:
A ref attribute is the internal name referenced by questions.
A Description is a human-readable label.
One or more QuestionLookup entries, each with an answer (display text) and a questionLookupUserCode (unique code).
Lookup options can optionally include a **score** attribute for assessment forms where answers carry a numeric weighting.
Pre-populate fields from person data
You can configure a question to automatically fill its value from the person record when the form is opened, using the dataSourceUri attribute.
Common pre-population patterns
URI pattern | What it resolves to |
`subject://person/firstNames` | The person's first names. |
`subject://person/dateOfBirth` | The person's date of birth. |
`subject://person/involvedParties/{answers.questionCode}/name` | The name of a related person, looked up using the value of another question. |
`subject://person/householdMembers/householdMember/name` | Household member names, used with repeating rows. |
`chronology://events/event/title` | Chronology event titles, used with repeating rows. |
π€ Tip: For repeating data (such as household members or chronology events), add a groupBy parameter to the URI to group the results into rows.
Cross-form pre-population
You can pre-populate a question from an answer on a different form template using a QuestionSource element within the question definition.
β
This requires:
The source form's templateUserCode.
The source question's questionUserCode.
A sourceFormSelectionCriterion to determine which instance of the source form is used (for example, LAST_STARTED uses the most recently started instance).
Question collections
To group related questions into repeating rows (for example, a list of family members), wrap them in a QuestionCollection.
Give the collection a questionCollectionUserCode.
Reference it in the view using a RepeatingTable or RepeatingSection element.
Set mandatory="true" on the collection if at least one row must be completed.
β
