jsn1nj4
jsn1nj4
FFilament
Created by jsn1nj4 on 8/5/2023 in #❓┊help
Change in `afterStateUpdated()` hook for file uploads?
@awcodes seems you're right, it's doing it. Something funky must've been happening when I was trying to organize the snippet below in an instance method. I've decided to just use a plain closure instead of handing off to a method.
->afterStateUpdated(static function (Forms\Set $set, TemporaryUploadedFile $state) {
$dto = ImageDTO::fromUpload($state);

$set('name', $dto->name);
$set('collection', $dto->collection);
$set('disk', $dto->disk);
$set('file_name', $dto->file_name);
$set('mime_type', $dto->mime_type);
$set('path', $dto->path);
$set('size', $dto->size);
$set('file_hash', $dto->file_hash);
})
->afterStateUpdated(static function (Forms\Set $set, TemporaryUploadedFile $state) {
$dto = ImageDTO::fromUpload($state);

$set('name', $dto->name);
$set('collection', $dto->collection);
$set('disk', $dto->disk);
$set('file_name', $dto->file_name);
$set('mime_type', $dto->mime_type);
$set('path', $dto->path);
$set('size', $dto->size);
$set('file_hash', $dto->file_hash);
})
Also had to manually set up state fields as described here: https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#saving-form-data-to-individual-properties Now have to figure out why my form fields are apparently not mapping to the model, but this is much bigger progress than I made before. Thanks!
8 replies
FFilament
Created by jsn1nj4 on 8/5/2023 in #❓┊help
Change in `afterStateUpdated()` hook for file uploads?
If you mean the one from this page, I'll give it a shot and see what I might be missing. Thanks! https://filamentphp.com/docs/3.x/panels/getting-started#the-demo-project
8 replies
FFilament
Created by jsn1nj4 on 8/5/2023 in #❓┊help
Change in `afterStateUpdated()` hook for file uploads?
Really, with Filament v3? Is it using Livewire V3 under the hood as well or v2?
8 replies
FFilament
Created by rabol on 7/18/2023 in #❓┊help
How do I get the file in a upload action
@steen.rabol just wanted to say, thanks, this helped me figure out what I needed for my image uploads too
10 replies