heisenberg1988
heisenberg1988
FFilament
Created by heisenberg1988 on 9/14/2023 in #❓┊help
Keybinding doesn't work after the first time
My idea is to use a modal to shoot tickets with an optical gun. The system is working, but when I open the modal, fill the user number (or shoot it with the gun) and press "enter", everything works and the modal stays open. But on the second insertion, if I press enter nothing happens, but if I press the button it works fine, but it loses autofocus on the form field. Could the problem be related to $action->halt()? Thank you This is my code in listPage
protected function getHeaderActions(): array
{
return [
Action::make('register_attendances')->label('Registra Presenza')
->form([
Section::make()
->schema([
TextInput::make('participant_id')
->autofocus()->numeric()->required()->label('Id Partecipante'),
])
])
->modalSubmitAction(false)
->extraModalFooterActions(fn(Action $action): array => [
$action->makeModalSubmitAction('registra', arguments: ['halt' => true])
->label('Registra')
->color('primary')
->keyBindings(['command+s', 'ctrl+s', 'enter'])
])
->action(function ($action, $record, $data, $arguments, $form) {
$attendance = Attendance::firstOrCreate($data);
$form->fill();
$action->halt();
})
];
}
protected function getHeaderActions(): array
{
return [
Action::make('register_attendances')->label('Registra Presenza')
->form([
Section::make()
->schema([
TextInput::make('participant_id')
->autofocus()->numeric()->required()->label('Id Partecipante'),
])
])
->modalSubmitAction(false)
->extraModalFooterActions(fn(Action $action): array => [
$action->makeModalSubmitAction('registra', arguments: ['halt' => true])
->label('Registra')
->color('primary')
->keyBindings(['command+s', 'ctrl+s', 'enter'])
])
->action(function ($action, $record, $data, $arguments, $form) {
$attendance = Attendance::firstOrCreate($data);
$form->fill();
$action->halt();
})
];
}
4 replies