Pattern input
The pattern input lets the user build a template out of free text and inline token chips — a
document-numbering pattern is the typical case: literal text like RE- mixed with tokens like a
sequential number, the year, or the month. Tokens are inserted from a menu, render as chips inline
with the surrounding text, and — when a token declares its own config schema — are clickable to
configure. Create one with PatternInput::make() and list the available tokens with ->tokens().
PatternInput::make('pattern', 'Number pattern') ->tokens([ PatternToken::make('NUMBER') ->label('Sequential number') ->configurable([ Choice::make('padding', 'Padding')->options([4 => '4', 5 => '5', 6 => '6'])->value(4), ]), PatternToken::make('YYYY')->label('Year (4-digit)'), PatternToken::make('MM')->label('Month'), ]) ->requiredTokens(['NUMBER'])- columnWidth:"md"
- conditions:null
- dependsOnAny:false
- dependsOnKeys:null
- disabled:false
- editablePrefill:false
- helperText:null
- label:"Number pattern"
- labelAction:null
- multiline:false
- name:"pattern"
- prefillRefreshOn:null
- prefillResetOn:null
- readOnly:false
- required:false
- rows:null
- separator:""
- tokens:[{"label":"Sequential number","name":"NUMBER","schema":[{"props":{"autoFocus":false,"columnWidth":"md","conditions":null,"dependsOnAny":false,"dependsOnKeys":null,"disabled":false,"editablePrefill":false,"helperText":null,"label":"Padding","labelAction":null,"name":"padding","optionSchema":null,"options":[{"data":null,"description":null,"group":null,"label":"4","tooltip":null,"value":"4"},{"data":null,"description":null,"group":null,"label":"5","tooltip":null,"value":"5"},{"data":null,"description":null,"group":null,"label":"6","tooltip":null,"value":"6"}],"prefillRefreshOn":null,"prefillResetOn":null,"readOnly":false,"required":false,"tabIndex":null,"tooltip":null,"value":4},"type":"field.choice"}]},{"label":"Year (4-digit)","name":"YYYY","schema":[]},{"label":"Month","name":"MM","schema":[]}]
- tooltip:null
- value:null
Stored value
Section titled “Stored value”The field submits an ordered array of segments — never a raw editor document. Each segment is either literal text or a placed token:
['pattern' => [ ['type' => 'text', 'value' => 'RE-'], ['type' => 'token', 'token' => 'NUMBER', 'config' => ['padding' => '4']], ['type' => 'text', 'value' => '-'], ['type' => 'token', 'token' => 'YYYY', 'config' => []],]]Reading this array is application logic — the field itself has no opinion on how a pattern like this turns into an actual document number.
On a multiline field, line breaks appear as \n inside text segments; single-line
fields reject values containing \n.
On the wire the client submits the segments as one JSON-encoded string — deliberately, so Laravel’s
TrimStrings middleware cannot strip leading/trailing whitespace (or multiline \n boundaries)
from individual text segments. Server-side casting always hands your handle() the decoded array,
but a ->dependsOn() closure sees the raw wire value — run it through PatternSegments::decode()
before reading segments.
Tokens
Section titled “Tokens”->tokens() takes the list of token types the pattern offers. Each is a PatternToken::make($name)
where $name is the value stored on every placed segment of that kind. Give it a human label with
->label() (defaults to a title-cased version of the name) and, if it needs configuration, a schema
of fields with ->configurable() — a normal array of fields, exactly like a Builder row’s schema:
PatternToken::make('NUMBER') ->label('Sequential number') ->configurable([ Choice::make('padding', 'Padding')->options([4 => '4', 5 => '5', 6 => '6'])->value(4), ]);A token without ->configurable() (like YYYY and MM above) renders as a plain chip with
nothing to click. Each token type can only be placed once per pattern — the insert menu hides a
token once it’s already in use.
Required tokens
Section titled “Required tokens”->requiredTokens() lists token names that must appear somewhere in the pattern for it to be valid:
PatternInput::make('pattern') ->tokens([PatternToken::make('NUMBER'), PatternToken::make('YYYY')]) ->requiredTokens(['NUMBER']);A submitted pattern missing a required token fails validation, alongside an unknown token name or the same token placed twice.
Separator
Section titled “Separator”->separator() sets the text inserted between a newly-placed chip and whatever’s already there when
a token is added from the menu — a convenience for the common case of dash- or slash-separated
patterns, not a stored or validated part of the value:
PatternInput::make('pattern')->separator('-');Multiline
Section titled “Multiline”->multiline() lets Enter start a new line — the pattern becomes a small block of text with chips,
for content like an address footer built from variables. Line breaks are stored as \n inside text
segments, so the wire format is unchanged. ->rows() sets the minimum visible height in text rows
(defaults to 3):
PatternInput::make('footer') ->tokens([...]) ->multiline() ->rows(5);Common options
Section titled “Common options”PatternInput shares label, required, disabled, read-only, and visibility options with every field
— see Fields. For validation and conditional behavior, see
Validation and Conditional fields.