FilamentF
Filament2y ago
w5m

Pass form data (`$state`) to `ChartWidget` in resource Create page

I have embedded a ChartWidget in a resource Create page (of type CreateRecord) via the getFooterWidgets() method.

Is there a way for the ChartWidget to access the data in the form fields (e.g. via a $state variable or similar) before the form is submitted (i.e. there is no record in the database table yet)?

What I'm trying to do is populate a chart after clicking a "Calculate" button (i.e. Action) on the form and would appreciate any thoughts as to how to approach this.

Many thanks.
Solution
where are you using this action?
I think you will need to inject $livewire..

->action(function($livewire) { 
  $livewire->dispatch('updateChartData', data: $livewire->data);
})
Was this page helpful?