Skip to content

integer

integer fields support whole number input, whether positive or negative. You may set minimum and maximum values using the min and max options.

Module field definition

javascript
// Configuring the `rating` field in a module's `fields.add` subsection:
rating: {
  label: 'Rate the movie from 1-5',
  type: 'integer',
  min: 1,
  max: 5
}

Settings

Required

PropertyTypeDefaultDescription
labelStringn/aSets the visible label for the field in the UI
typeStringn/aSpecifies the field type (float for this type)

Optional

PropertyTypeDefaultDescription
defNumbern/aThe default value for the field
helpStringn/aHelp text for the content editor
htmlHelpStringn/aHelp text with support for HTML markup
ifObject{}Conditions to meet before the field is active. See the guide for details.
requiredIfObject{}Conditions to meet before the field is required. See the guide for details.
hiddenBooleanfalseIf true, the field is hidden
maxNumbern/aThe maximum allowed value for the field
minNumbern/aThe minimum allowed value for the field
requiredBooleanfalseIf true, the field is mandatory
readOnlyBooleanfalseIf true, prevents the user from editing the field value

Use in templates

This example uses a Nunjucks for tag and range function.

nunjucks
{{ data.piece.rating }}

{# data.piece.stars is a number #}
Rating:
{% for i in range(1, data.piece.stars) -%}
  ⭐️
{%- endfor %}