Trouble with a read-only field for a model relationship

I have a model SystemLog with a relationship retryingUser. When I save the form - I'm getting the error Add fillable property [retryingUser] to allow mass assignment on [App\Models\SystemLog]. Even though I've got the field set as disable, readOnly and dehydrated = false. So I think Filament really shouldn't be trying to save the field - but I must have something wrong! I want to display the value, but it's not editable at all. Any suggestions for what I should be doing differently? Here's an excerpt from mySystemLogResource:
class SystemLogResource extends Resource
{
protected static ?string $model = SystemLog::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('retryingUser.name')
->label('Retrying User')
->disabled()
->readOnly()
->dehydrated(false),
]);
}
class SystemLogResource extends Resource
{
protected static ?string $model = SystemLog::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('retryingUser.name')
->label('Retrying User')
->disabled()
->readOnly()
->dehydrated(false),
]);
}
3 Replies
Majid Al Zariey
Would be better to use a Select Field instead , Or a Placeholder would be best
Patabugen
PatabugenOP2w ago
Thanks @Majid Al Zariey placeholder looks like it might be the one - many thanks! To understand what's happening though - from reading the docs - it shouldn't make much difference, since Filament shouldn't be trying to save the value anyway. With disabled, readOnly and dehydrated(false)
Dennis Koch
Dennis Koch2w ago
My guess: The issue might come from using the dot syntax here.

Did you find this page helpful?