F
Filamentβ€’10mo ago
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),
]);
}
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.
3 Replies
ModestasV
ModestasVβ€’10mo ago
Hidden fields are not sent to the create form if I'm not mistaken. But it would help if you could add the exact error you are getting πŸ™‚
backtrackjack
backtrackjackβ€’10mo ago
full stack trace
backtrackjack
backtrackjackβ€’10mo ago
but that sounds right, if it won't let me create with hidden on. thanks