☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

max_items

Table of contents

Description:

This key defines the maximum number of items CloudCannon will allow in an Input.

When configured, CloudCannon will prevent you from adding more items to this Input.

If the Input already contains more items, CloudCannon will require you to remove items until the Input contains a valid number to save your changes, or discard your unsaved changes.

Value can be any positive integer.

If options.min_items is also configured, this key cannot be a lesser number.

This key has no default.

This key is available for Array and Multiselect or Multichoice Inputs.

Appears in:
└── _inputs
    └── *
        ├── Multiselect Input
        │   └── options
        │       └── max_items
        ├── Multichoice Input
        │   └── options
        │       └── max_items
        └── Array Input
            └── options
                └── max_items
Type:
number
Examples:

In this example, we want to add an array of filepaths to our homepage's featured_posts Input. This Input limits you to a maximum of five array items.

Copied to clipboard
_inputs:
  featured_posts:
    type: array
    options:
      max_items: 5
      max_items_message: Cannot be more than 5
      min_items: 2
      min_items_message: Cannot be less than 2
{
  "_inputs": {
    "featured_posts": {
      "type": "array",
      "options": {
        "max_items": 5,
        "max_items_message": "Cannot be more than 5",
        "min_items": 2,
        "min_items_message": "Cannot be less than 2"
      }
    }
  }
}
Open in a new tab