FilamentF
Filament3y ago
4 replies
backtrackjack

`->hidden()` method on TextInput field breaks app

I have this code on a filament resource:
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('owner_type')->default('user')->hidden(),
                TextInput::make('owner_id')
                    ->default(auth()->user()->id)->hidden(),
                TextInput::make('title')->required()->maxLength(255),
            ]);
    }


This record has a polymorphic relation with it's "owner" which I would like to default to a user. I have created the morph map in a service provider.

This code throws a SQL error "owner_type" / "owner_id" cannot have a default value, however when I remove the hidden method on both fields, the record is created fine.

Not sure what else to try, cheers.
Was this page helpful?