You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to get this setup on a new project I've just started. I'm fairly new using filament so it is porobably something simple I've missed.
I've created the widget basically by copy and pasting from the docs at this stage to try and get it work but it appears the getFormSchema function is not being called as my $form variable is empty. If I remove the mountUsing parts I can get the page to open but when I click the new button there are no form fields listed. just a heading and the normal buttons (create, create and make another, cancel).
<?php
namespace App\Filament\Widgets;
use App\Models\Event;
use Filament;
use Filament\Actions\Action;
use Filament\Forms;
use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;
use Saade\FilamentFullCalendar\Widgets\FullCalendarWidget;
class CalendarWidget extends FullCalendarWidget implements Forms\Contracts\HasForms
{
use Forms\Concerns\InteractsWithForms;
public Model | string | null $model = Event::class;
public function config(): array
{
return [
'firstDay' => 1,
'headerToolbar' => [
'left' => 'dayGridWeek,dayGridDay',
'center' => 'title',
'right' => 'prev,next today',
],
];
}
public function eventDidMount(): string
{
return <<<JS
function({ event, timeText, isStart, isEnd, isMirror, isPast, isFuture, isToday, el, view }){
el.setAttribute("x-tooltip", "tooltip");
el.setAttribute("x-data", "{ tooltip: '"+event.title+"' }");
}
JS;
}
public function fetchEvents(array $fetchInfo): array
{
return Event::query()
->where('starts_at', '>=', $fetchInfo['start'])
->where('ends_at', '<=', $fetchInfo['end'])
->get()
->map(
fn (Event $event) => [
'title' => $event->id,
'start' => $event->start,
'end' => $event->end,
'url' => EventResource::getUrl(name: 'view', parameters: ['record' => $event]),
'shouldOpenUrlInNewTab' => true
]
)
->all();
}
protected function headerActions(): array
{
return [
Filament\Actions\CreateAction::make()
->mountUsing(
function (Forms\Form $form, array $arguments) {
$form->fill([
'starts_at' => $arguments['start'] ?? null,
'ends_at' => $arguments['end'] ?? null
]);
}
)
];
}
protected function modalActions(): array
{
return [
Filament\Actions\EditAction::make()
->mountUsing(
function (Event $record, Forms\Form $form, array $arguments) {
$form->fill([
'name' => $record->name,
'starts_at' => $arguments['event']['start'] ?? $record->starts_at,
'ends_at' => $arguments['event']['end'] ?? $record->ends_at
]);
}
),
Filament\Actions\DeleteAction::make(),
];
}
protected function viewAction(): Action
{
return Filament\Actions\ViewAction::make();
}
public function getFormSchema(): array
{
return [
Filament\Forms\Components\TextInput::make('name'),
Filament\Forms\Components\Grid::make()
->schema([
Filament\Forms\Components\DateTimePicker::make('starts_at'),
Filament\Forms\Components\DateTimePicker::make('ends_at'),
]),
];
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Trying to get this setup on a new project I've just started. I'm fairly new using filament so it is porobably something simple I've missed.
I've created the widget basically by copy and pasting from the docs at this stage to try and get it work but it appears the getFormSchema function is not being called as my $form variable is empty. If I remove the mountUsing parts I can get the page to open but when I click the new button there are no form fields listed. just a heading and the normal buttons (create, create and make another, cancel).
Beta Was this translation helpful? Give feedback.
All reactions