Select field using search populate another field.

I have a select field that populates the options via an external API request:
Forms\Components\Select::make('ticket_number')
->searchable()
->getSearchResultsUsing(fn (string $search): array => \App\Models\Ticket::apiTickets($search))
->selectablePlaceholder(false)
->searchingMessage('Searching Tickets...')
->native(false)
->live(),

Forms\Components\TextInput::make('ticket_title')->readOnly(),
Forms\Components\Select::make('ticket_number')
->searchable()
->getSearchResultsUsing(fn (string $search): array => \App\Models\Ticket::apiTickets($search))
->selectablePlaceholder(false)
->searchingMessage('Searching Tickets...')
->native(false)
->live(),

Forms\Components\TextInput::make('ticket_title')->readOnly(),
How can I pass the selected result over to the TextInput field? I couldn't figure this out using afterStateUpdated with the getSearchResultsUsing method on the original field.
2 Replies
BKF Dev
BKF Dev7mo ago
Add this method to select : ... ->live() ->reactive() ->afterStateUpdated(function ($state, Set $set) {
$set('ticket_title', $state); }),
krekas
krekas7mo ago
reactive() is changed to live() in v3. they both do the same
Want results from more Discord servers?
Add your server