Thandruil
Thandruil
FFilament
Created by Thandruil on 6/15/2023 in #❓┊help
[V3] Removing upload from FileUpload does not trigger `afterStateUpdated`
Hiya! Testing our project on V3 and found this bug(?) or at least unexpected behaviour. I have this FileUpload field in a form with multiple files allowed. Whenever you upload a file I need to execute some code, which I do using afterStateUpdated. This works perfectly fine for adding files, but it's not called when you remove a file.
FileUpload::make('uploads')
->multiple()
->storeFiles(false)
->afterStateUpdated(function (array $state, Get $get, Set $set) {
collect($state)->map(fn (TemporaryUploadedFile $file, $key) => do_something());
}),
FileUpload::make('uploads')
->multiple()
->storeFiles(false)
->afterStateUpdated(function (array $state, Get $get, Set $set) {
collect($state)->map(fn (TemporaryUploadedFile $file, $key) => do_something());
}),
18 replies
FFilament
Created by Thandruil on 5/30/2023 in #❓┊help
Expose group of fields as a new single reusable field
Hi there! First of all thank you for this amazing framework! I'm looking to build a reusable from input/component. It's a text input and a select. Ideally I'd provide this field as a new component that exposes a single value to the form state. I see two ways of making this work: 1. Build a group/component that has it's own schema of Input and Select.
class MonetaryInput extends Group
{
public static function make()
{
$this->schema([
Input::make(),
Select::make(),
])
}
}
class MonetaryInput extends Group
{
public static function make()
{
$this->schema([
Input::make(),
Select::make(),
])
}
}
Is there a go-to way of doing this? Ideally I can reuse the existing Input and Select like in the example above. Is there a way of exposing a single named property to the form state? 2. Build a view component and write the input/select myself. Downside is that you would have to implement the inputs and selects and can't really reuse the existing filament input components.
18 replies