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 Inputfield
class also inherits all the methods and properties of: Inputfield, WireData and Wire.
Common
Name | Return | Summary | |
---|---|---|---|
Inputfield Inputfield Inputfield | self | Add multiple selectable options | |
Inputfield Inputfield Inputfield | array | Get all attributes in an associative array | |
Inputfield Inputfield Inputfield | bool | Set page selector |
Settings
Helpers
Name | Return | Summary | |
---|---|---|---|
Inputfield Inputfield Inputfield | array | Static utility function to convert a tags string to an array of [ 'tag' => 'label' ] |
Properties
Name | Return | Summary | Default |
---|---|---|---|
Inputfield | int bool | Allow user-entered tags? | false |
Inputfield | array | Read-only property of selected tags in an array | [] |
Inputfield | int bool | Close select dropdown box after user makes selection? | true |
Inputfield | string | One of 's' (for space ' '), 'p' (for pipe '|') or 'c' (for comma). | s |
Inputfield | int | Max selectable items, 0 for no limit, 1 for single-select mode, or 2+ to limit selection to that number. | 0 |
Inputfield | int | Alias of maxItems (as used by InputfieldPage) | 0 |
Inputfield | string null | Selector for finding pages, for InputfieldSupportsPageSelector interface | null |
Inputfield | string | Placeholder string to show when no options selected. | blank |
Inputfield | array string | Array of tags [ 'tag' => 'label' ], or newline separated string of "tag=label", or use addTag() to populate. | [] |
Inputfield | string | Remote URL to find tags from, must have a '{q}' in it somewhere, which will be replaced with the query. | blank |
Inputfield | bool int | Whether ajax mode is enabled, used internally | false |
Inputfield | string | Value attribute of selected tags separated by delimiter | blank |
Additional methods and properties
In addition to the methods and properties above, Inputfield
API reference based on ProcessWire core version 3.0.251