#KeyValue UI not updating after $set(), but the value is changed

3 messages · Page 1 of 1 (latest)

sage mulch
#

Hi Guys,

I am using a button to change the keys and/or values in a KeyValue field that already contains data.
When i do this the UI does not change, but the value will.

return $form
    ->schema([
        ...
        Forms\Components\KeyValue::make('meta'),
        ...
        Forms\Components\Actions::make([
            Forms\Components\Actions\Action::make('button')
                ->action(function (Set $set) {
                    $set('meta.a', 'foo');
                    $set('meta.b', 'bar');
                    $set('meta.c', 'baz');
                }),
        ...

The weird thing is that it works when the meta field is either NULL or an empty array, OR when i manually make a change to the KeyValue field first.

Am i doing something wrong or is this a bug?

Thanks in advance!

repo:
https://github.com/rickzim/demo-filament-key-value

GitHub

Contribute to rickzim/demo-filament-key-value development by creating an account on GitHub.

junior viperBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

sage mulch
#

bump