Skip to content

TagsInput

Free text tags, saved as a JSON list in one column.

use Anvil\Schema\Fields\TagsInput;
TagsInput::make('keywords')->suggestions(['urgent', 'internal', 'customer'])->maxItems(10),
TagsInput::make('skills')->maxLength(30)->helperText('Enter or comma adds a tag.'),
Option Effect Default
suggestions([…]) offered while typing; other values are allowed none
maxItems(n) most tags 20
maxLength(n) most characters per tag 50

Plus the options of every field.

Enter or a comma adds the typed tag, leaving the input adds it too (a comma inside a tag becomes a space; a tag that exists in another case is not added again). Backspace in the empty input removes the last tag; each tag has a remove button. When maxItems is reached no further tag is added.

A JSON list of strings (use a JSON or TEXT column): tags are trimmed, empty ones dropped and duplicates removed case-insensitively (the first spelling is kept). No tags: null.

is_array, max_count[n] for the field, string and max_length[n] for every tag (keywords.*). required() needs at least one tag.

The tags as badges.

An array of strings with maxItems and maxLength.