Editing columns in Template Manager

Developer page

Template manager page

Basics

Every column in a table/model must have a unique name. The name must be written in "snake case" (opens new window), e.g. "drilled_length". Except for some cases (see "Pseudo column values", mentioned below) every column in a form/model represents a column in a database table.

Edit a data model template in the template manager.
To create a new Column, click the button "Add column", enter a column name and confirm with "OK".

Open the pane of the newly created column and enter these attributes:

edit column

Label

The label is used in some reports and is permanently shown in a form. When you create a form for a model, you can modify the label of the field.

  • attribute in JSON file in dis_templates/models folder: "label"

Description

The description is only used in forms and can be modified when editing a form in the template manager. Is is only displayed when a form field gets the input focus. So it is not visible for fields that cannot be edited.

  • attribute in JSON file in dis_templates/models folder: "description"

Original Column Name

The previous name of the column. If you rename a column, the old name is stored in the model and displayed here. If you "Save & Generate" a model with a column that has a different original column (editor: ?)

  • Optional attribute in JSON file in dis_templates/models folder: "oldName"

Type

The type of the column:

  • Integer: integer number
  • Double: decimal number
  • Boolean: True/false, Yes/No, etc. Is stored as 1/0 in the database.
  • String: Single line text with limited length
  • String (multiple): List of single line texts delimited by ";"
  • DateTime: Date with time
  • Date: Date (without time)
  • Time: Time
  • Text: Longer (multi line) text
  • Pseudo: Column does not appear in the database but its value is calculated in PHP. The column is read-only. You have to enter an expression to calculate the value.

Depending on the type the user interface can differ when the column is used in a form.

  • attribute in JSON file in dis_templates/models folder: "type"

Size

Only for some types a size can be entered, i.e. to limit the length of a string column.

  • attribute in JSON file in dis_templates/models folder: "size"

Required

This column must have a value. If it is empty, the record cannot be saved.

  • attribute in JSON file in dis_templates/models folder: "required"

Validator

The values of this column allow the following types of validation:

  • "integer value" / "numeric value": Require integer numbers or floating-point numerics (in text fields)

  • > a, < a, >= a, <= a, <> a, != a, = a : Mathematical comparison operators for the entered value a. Both <> a and != a mean the same thing, "unequal to".

  • between <a> and <b>: Value must be within the given range

  • in ("<a>","<b>","<c>","<d>"): Value must be among the given list of value. The values in the list must be comma separated.

  • LIKE <regular expression>: Value must match the regular expression

  • attribute in JSON file in dis_templates/models folder: "validator"

Pseudo column values

  • only for column type: "pseudo"

The column cannot be edited, its value is calculated when the record is loaded. There a two different types of pseudo columns:

  1. To directly access an ancestor column you can use a syntax like parent.parent.name.
    • Values in a pseudo column like this can be searched for using the custom search.
  2. Enter valid PHP code. You can use other columns or values of related records. You can also call methods of the model (see below)
    • Values in pseudo columns with PHP code can not be searched for with the custom search
  • attribute in JSON file in dis_templates/models folder: "pseudoCalc"

Unit of Measure

The unit of measure is just a text that is displayed in square brackets after the label of field in a form. mDIS does not check if the unit is semantically correct or physically meaningful.

  • attribute in JSON file in dis_templates/models folder: "unit"

Calculate

The column cannot be edited but is calculated when the record is saved. You have to enter valid PHP code and can access other columns of the records or related records.

In the code you can also call more complex PHP methods available in the model. For some domain models methods have been provided for such purposes. In backend/modules/cg/generators/DISModel/specializations you can find some examples for this. The code generator of the template manager adds the extra methods of the files here. This way, methods "getSplitStatus()" and "getSectionTop()" are added to the class in backend/models/base/BaseCoreSection.php.

The value of a calculated column

  • attribute in JSON file in dis_templates/models folder: "calculate"

Default value

Default value for new records.

Only constants can be entered here.

  • attribute in JSON file in dis_templates/models folder: "defaultValue"