Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed property Saade\FilamentFullCalendar\Widgets\FullCalendarWidget::$record must not be accessed before initialization #131

Open
darren-glanville opened this issue Nov 25, 2023 · 2 comments

Comments

@darren-glanville
Copy link

I have a filament action within headerActions method for the calendar.

It is using a modal form which I want to run to filter the events, the error appears when trying to submit that form. Any ideas on how to fix this would be much appreciated.

return [ Action::make('filter') ->label(__('ev-bookings.actions.filter-locations')) ->icon('heroicon-s-funnel') ->modalWidth('sm') ->modalIcon('heroicon-o-funnel') ->modalCancelAction(false) ->modalSubmitActionLabel(__('ev-bookings.actions.filter-locations')) ->modalFooterActionsAlignment('center') ->form([ CheckboxListColor::make('color') ->label(__('ev-bookings.fields.locations')) ->hiddenLabel(true) ->options($locations) ->required() ->columns(2) ]) ->action(function (array $data): void { // will do something }) ];

@Hegabovic
Copy link

i'm having the same error when creating Events with additional data

this line gives this error : 'calendar_id' => $this->record->id

@FinnPaes
Copy link

I had the same issue. It's because you didn't define the model in the calendar widget like this:

public Model | string | null $model = Appointment::class;
In my case my model is Appointment, so of course change that to the model which contains your events/dates.
Full example:

<?php

namespace App\Filament\Widgets;

use App\Models\Appointment;
use Illuminate\Database\Eloquent\Model;
use Saade\FilamentFullCalendar\Data\EventData;
use Saade\FilamentFullCalendar\Widgets\FullCalendarWidget;

class CalendarWidget extends FullCalendarWidget
{
    public Model | string | null $model = Appointment::class;
    
    public function fetchEvents(array $fetchInfo): array
    {
        return Appointment::query()
            ->where('start', '>=', $fetchInfo['start'])
            ->where('end', '<=', $fetchInfo['end'])
            ->get()
            ->map(
                fn (Appointment $appointment) => EventData::make()
                    ->id($appointment->id)
                    ->title($appointment->title)
                    ->start($appointment->start->toDateTimeLocalString())
                    ->end($appointment->end->toDateTimeLocalString())
            )
            ->toArray();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants