FilamentF
Filament3y ago
Vp

call to member function on null in select with relationship

What should be the error here, my code
public function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\Tabs::make('Label')
                ->tabs([
                    Forms\Components\Tabs\Tab::make('Personal details')
                        ->schema([
                            Forms\Components\Grid::make()
                                ->schema([
                                    Forms\Components\Select::make('languages.name')
                                        ->label('Languages')
                                        ->required()
                                        ->multiple()
                                        ->relationship(name: 'languages', titleAttribute: 'name')
                                        ->searchable()
                                        ->preload(),
                                ]),
                        ]),
                ]),
        ]);
}

// relationship
public function languages(): BelongsToMany
{
    return $this->belongsToMany(Language::class);
}

// blade.php
{{ $this->form }}

I also put $this->form->fill(); in mount()
Was this page helpful?