Suggest
Free text with autocomplete over a fixed candidate set. As you type, candidates
are fuzzy-matched and ranked by relevance. It is an open set - it collects a
string, which need not be one of the candidates.
$p->suggest('fruit', 'Fruit')
->options([
'Apple' => 'Apple',
'Apricot' => 'Apricot',
'Banana' => 'Banana',
'Cherry' => 'Cherry',
'Mango' => 'Mango',
])
->default('Apple') // Initial text.
->pageSize(8); // Suggestions visible before the list pages.
Runnable script: playground/02-widgets/suggest.php.
Options
| Name | Description | Required | Default |
|---|---|---|---|
options() | The candidate set to autocomplete against; only the values are used. | No | None |
default() | Initial text. | No | '' (empty) |
pageSize() | Suggestions shown before the list pages around the cursor. | No | 10 |
Because the set is open, Enter accepts the highlighted suggestion, or your
typed text as-is when none is highlighted.
Keyboard
| Key | Action |
|---|---|
| printable keys | Type to filter the candidates |
↑ / ↓ | Highlight a suggestion |
Backspace | Delete the character before the caret |
Enter | Accept the highlighted suggestion, or the typed text if none |
Esc | Cancel |
Display modes
In all four display modes - Unicode or ASCII, colour on or off:
| ANSI | No ANSI | |
| Unicode | ||
| ASCII |