Temporary files are never moved
I am using Filament's Wizard for a multi-step form. On step 1, the model is created. On the last step, some files are uploaded. Those files make it to the livewire-tmp directory, but they are never moved after the form is submitted.
The files are not renamed or moved. I feel like I probably need to call a method to process the files, but the documentation doesn't mention it.
11 Replies
Iirc you have to use ->visibility(‘private’) in order to upload to s3
Thanks. I just tried that and it also didn't work.
Even this doesn't work, so I think I need to call some Filament method(s) to process tmp uploads
Saving the form is what moves and processes the temp files. Maybe it has something to do with saving the model up front instead of on form submission.
You can try a FileUpload in a non wizard context to help troubleshoot.
It works as expected in a non-wizard, non-model-created-on-first step setup. How does Filament know create() on my Livewire component is being called?
It’s the default form submit action.
A wizard is just one big form that just shows and hides its respective form fields.
I'm confused. What is "the default form submit action?" https://filamentphp.com/docs/3.x/forms/layout/wizard#rendering-a-submit-button-on-the-last-step mentions wiring up a Livewire method to handle form submission, which is what I have done.
Wiring it up depends on if you are using the wizard with panels or in a standalone livewire component.
Standalone livewire component is what I'm using.
Are you calling $this->form->getState() in your save / submit for the form?
GetState() will run the validations and process the form data including file uploads.
Ah, no, we stopped using it because it did something automagical that was breaking our form. I can't remember what, specifically. Ok, switched from getRawState() to getState() and the file upload and moving all works!
Thanks.
Tacking on to this. The reason we don't use getState() is because it runs the validations for all steps, so if there are required fields on step 4, but step 1 is being completed, it fails because it's trying to tell the use that a field on step 4 (which they haven't gotten to yet) is required.
Yea. I get it, so you’ll need to dive into the getState and see how it’s applying the file handling and replicate that for the individual step.
You’re trying to use the wizard as a multiple form instead of steps in a form so it going to require a more granular custom approach.