# 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

// 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

Property Type Default Description
label String n/a Sets the visible label for the field in the UI
type String n/a Specifies the field type (float for this type)

# Optional

Property Type Default Description
def Number n/a The default value for the field
help String n/a Help text for the content editor
htmlHelp String n/a Help text with support for HTML markup
if Object {} Conditions to meet before the field is active. See the guide for details.
max Number n/a The maximum allowed value for the field
min Number n/a The minimum allowed value for the field
required Boolean false If true, the field is mandatory

# Use in templates

This example uses a Nunjucks for tag (opens new window) and range function (opens new window).

{{ data.piece.rating }}

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