Filament Form + Livewire: Updating Field Without Saving to Database

I’m working with Filament v3 and Livewire v3 and trying to dynamically update a form field without saving to the database. Scenario: • I have a HasManyRepeater inside a Filament resource (WordSetResource). • Each word has an example field that should be generated using OpenAI when a button is clicked. • The example field should update in the form, but not persist to the database until the user submits.
No description
4 Replies
Dhru
Dhru3w ago
maybe something like... Action::make('example') ->label('Generate Example") ->action(function ($livewire) { $form = $livewire->form->getState(); $form["example"] = "example text"; $livewire->form->fill($form); }),
toeknee
toeknee3w ago
add:
->dehydrated(false)
->dehydrated(false)
to the fields you do not want to save.
jamespickard
jamespickardOP3w ago
Is that use Filament\Forms\Components\Actions\Action ? I get an error Filament\Forms\ComponentContainer::Filament\Forms\Concerns\{closure}(): Argument #1 ($component) must be of type Filament\Forms\Components\Component, Filament\Forms\Components\Actions\Action given
jamespickard
jamespickardOP3w ago
I am reading here: https://filamentphp.com/docs/3.x/forms/advanced#inserting-livewire-components-into-a-form And I can't figure out how to access unsaved fields from the form in my livewire component

Did you find this page helpful?