Skip to main content

Suggest

Suggest widgetSuggest widget

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

NameDescriptionRequiredDefault
options()The candidate set to autocomplete against; only the values are used.NoNone
default()Initial text.No'' (empty)
pageSize()Suggestions shown before the list pages around the cursor.No10

Because the set is open, Enter accepts the highlighted suggestion, or your typed text as-is when none is highlighted.

Keyboard

KeyAction
printable keysType to filter the candidates
/ Highlight a suggestion
BackspaceDelete the character before the caret
EnterAccept the highlighted suggestion, or the typed text if none
EscCancel

Display modes

In all four display modes - Unicode or ASCII, colour on or off:

ANSINo ANSI
UnicodeSuggest: Unicode + ANSISuggest: Unicode + ANSISuggest: Unicode + No ANSISuggest: Unicode + No ANSI
ASCIISuggest: ASCII + ANSISuggest: ASCII + ANSISuggest: ASCII + No ANSISuggest: ASCII + No ANSI