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
directionString'ltr'Sets the text direction for the field. Use 'ltr' for left-to-right or 'rtl' for right-to-left. Overrides the locale's default direction. See the RTL language support guide for details.
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 Array.from() to repeat markup a set number of times.

jsx
{piece.rating}

{/* piece.stars is a number */}
Rating:
{Array.from({ length: piece.stars }, (_, i) => (
  <span>⭐️</span>
))}