FilamentF
Filament8mo ago
4 replies
Patabugen

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),
            ]);
    }
Was this page helpful?