return $form
->schema([
Forms\Components\TextInput::make('social_security_number')
->suffixAction(
Action::make('fetchSocialSecurityInfo')
->icon('heroicon-o-magnifying-glass')
->action(function (Set $set, $state) {
// Check for empty values
if (blank($state)) {
return;
}
// Consume your API
try {
$response = Http::post('https://your-api.com/api/social', ['social_security_number' => $state])->throw()
} catch (Exception) {
Filament::notify('danger', 'Something went wrong');
}
// Set the state of all the other fields
$set('name', $response['name'])
$set('phone', $response['phone'])
// ...
})
)
])
return $form
->schema([
Forms\Components\TextInput::make('social_security_number')
->suffixAction(
Action::make('fetchSocialSecurityInfo')
->icon('heroicon-o-magnifying-glass')
->action(function (Set $set, $state) {
// Check for empty values
if (blank($state)) {
return;
}
// Consume your API
try {
$response = Http::post('https://your-api.com/api/social', ['social_security_number' => $state])->throw()
} catch (Exception) {
Filament::notify('danger', 'Something went wrong');
}
// Set the state of all the other fields
$set('name', $response['name'])
$set('phone', $response['phone'])
// ...
})
)
])