Navigate between records on ViewAction
Hi,
Following the doc, I'm trying to perform an action in the extraModalFooterActions, I'd like to reset the form and not close the modal as indicated in the doc as a comment.
Can anyone explain how to do this ? (
// Reset the form and don't close the modal
)
Thanks !20 Replies
$this->form->reset() ? or $this->reset?
or $this->form->fill([])
i can't use $this in ->action()
Using $this when not in object context
Here my code :
I have no errors, but the form fields do not update with the new record.I am unsure what you are trying to do, are you trying to change the loaded record within the model?
I would like to make prev and next buttons that allow me to navigate between model records in the modal
Now the next button works, but the form loses the record and I don't know how to set the new record :
First screen : click on table row => open modal
Second screen : click on "Next record" button
The next record isn't set on the form...
Usually you would use mountUsing or pass in the record like you have. If you adjust the action to use mountUsing, you might be able to use $form->fill()? Since the model will be detacted.
You'll likely need to build the save method into ->action() then though.
I did it using pages https://github.com/filament-br/infolist-example/blob/page-actions/screenshots/example-1.gif
GitHub
infolist-example/screenshots/example-1.gif at page-actions Ā· filame...
Filament infolist example. Contribute to filament-br/infolist-example development by creating an account on GitHub.
I see, I'll try to adapt it to my ViewAction, thanks !
The actions: https://github.com/filament-br/infolist-example/tree/page-actions/app/Filament/Resources/Actions
The trait: https://github.com/filament-br/infolist-example/blob/page-actions/app/Filament/Resources/Pages/Concerns/CanPaginateViewRecord.php
āļø
GitHub
infolist-example/app/Filament/Resources/Actions at page-actions Ā· f...
Filament infolist example. Contribute to filament-br/infolist-example development by creating an account on GitHub.
GitHub
infolist-example/app/Filament/Resources/Pages/Concerns/CanPaginateV...
Filament infolist example. Contribute to filament-br/infolist-example development by creating an account on GitHub.
Nice, I'd seen š
You can clone this repo and use this branch
page-actions
if you want. This is working
Check the ViewPost page šBut as I don't use pages, but a modal, I have to change the record to next or previous, so how to do instead of
$action->url(fn (): string => static::getResource()::getUrl(static::getResourcePageName(), ['record' => $this->getNextRecord() ]));
in your trait ? šnot sure, $action->record maybe?
The record doesn't change with the next or the prev... and I have no errors :
When you click on prev or next, the new record is applied to the action, but the fields in the form are not updated
I've also tried using ->fillForm(), but it doesn't work either
I'm not sure you can do this once it has loaded tbh
are you using a resource simple, right?
Yes
i call my Action like that :
ok, try to inject your ManagePage and use mountedTableActionsData
Just to try it...
This pretty much works, not all of my fields are completely populated. I think it's a good lead in any case. I'll continue to dig in this direction. Thanks ! š
Yes. It could be better š