F
Filament9mo ago
cakan

Widget with datepicker

I'm trying to make a widget that will be displayed on a Dashboard. Widget displays some statistics based on the selected date. I've created a Widget with a form and added form to the layout, but I'm having trouble how to get date from the form and pass it to my report function. This is my code:
class MonthlyReport extends Widget implements HasForms
{
use InteractsWithForms;

protected static string $view = "filament.resources.user-resource.widgets.monthly-report";

public function getMonthlyReports(): array
{
return ActionHistoryHelper::getReport(Carbon::now()->format('Y-m-d'));
}

public function form(Form $form): Form
{
return $form->schema([DatePicker::make('date')]);
}
}
class MonthlyReport extends Widget implements HasForms
{
use InteractsWithForms;

protected static string $view = "filament.resources.user-resource.widgets.monthly-report";

public function getMonthlyReports(): array
{
return ActionHistoryHelper::getReport(Carbon::now()->format('Y-m-d'));
}

public function form(Form $form): Form
{
return $form->schema([DatePicker::make('date')]);
}
}
View is just displaying the form and the data received from getMonthlyReports function. How do I pass the date value from form to the getMonthlyReports function and refresh the widget?
0 Replies
No replies yetBe the first to reply to this messageJoin