InputfieldTextTags class

Enables input of user entered tags or selection of predefined tags.

// create a text tags Inputifeld
$f = $modules->get('InputfieldTextTags');
$f->attr('name', 'tags');

// allow for user-entered tags input (true or false, default=false)
$f->allowUserTags = true;

// predefined selectable tags (tag and optional label)
$f->addTag('foo');
$f->addTag('bar', 'This is Bar'); // optional label
$f->addTag('baz', 'This is Baz'); // optional label

// set currently entered/selected tags
$f->val('foo bar');
$f->val([ 'foo', 'bar' ]); // this also works

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the InputfieldTextTags class also inherits all the methods and properties of: Inputfield, WireData and Wire.

Show class?     Show args?       Only hookable?    

Helpers

NameReturnSummary 
InputfieldTextTags::tagsArray(Field $field)
arrayStatic utility function to convert a tags string to an array of [ 'tag' => 'label' ] 

Properties

NameReturnSummaryDefault
InputfieldTextTags::allowUserTags int bool Allow user-entered tags? false
InputfieldTextTags::arrayValue array Read-only property of selected tags in an array []
InputfieldTextTags::closeAfterSelect int bool Close select dropdown box after user makes selection? true
InputfieldTextTags::delimiter string One of 's' (for space ' '), 'p' (for pipe '|') or 'c' (for comma). s
InputfieldTextTags::maxItems int Max selectable items, 0 for no limit, 1 for single-select mode, or 2+ to limit selection to that number. 0
InputfieldTextTags::maxSelectedItems int Alias of maxItems (as used by InputfieldPage) 0
InputfieldTextTags::pageSelector string null Selector for finding pages, for InputfieldSupportsPageSelector interface null
InputfieldTextTags::placeholder string Placeholder string to show when no options selected. blank
InputfieldTextTags::tagsList array string Array of tags [ 'tag' => 'label' ], or newline separated string of "tag=label", or use addTag() to populate. []
InputfieldTextTags::tagsUrl string Remote URL to find tags from, must have a '{q}' in it somewhere, which will be replaced with the query. blank
InputfieldTextTags::useAjax bool int Whether ajax mode is enabled, used internally false
InputfieldTextTags::value string Value attribute of selected tags separated by delimiter blank

Additional methods and properties

In addition to the methods and properties above, InputfieldTextTags also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.251