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.'),Options
Section titled “Options”| 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.
Editing
Section titled “Editing”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.
Saved value
Section titled “Saved value”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.
Validation
Section titled “Validation”is_array, max_count[n] for the field, string and max_length[n] for
every tag (keywords.*). required() needs at least one tag.
Read-only
Section titled “Read-only”The tags as badges.
An array of strings with maxItems and maxLength.