Why doesn't my placeholder work on columns with relationships?

I've set up a relationship between Customer and Account models. class Customer extends Model { public function account(): HasOne { return $this->hasOne(Account::class, 'contactid'); } } class Account extends Model { public function individual(): BelongsTo { return $this->belongsTo(Individual::class, 'contactid'); } } So when I create an infolist with the section below the correct field values are loaded. The problem is that when the values are null the placeholder does not show for account.name. Section::make('Customer Details') ->schema([ TextEntry::make('account.name') ->label('Account ID') ->placeholder('empty'), //This never shows TextEntry::make('fullname') ->label('Account Type'), //This shows ok )] This behaviour seems to happen for all TextEntry fields that use relationships for their values. I've even checked dd($this->customer->account) and I can see that the name is null.
Solution:
I've found a way round this. Add this to the TextEntry: ->getStateUsing(fn ($record) => $record->account->name ?? null)...
Jump to solution
1 Reply
Solution
urbycoz
urbycoz6mo ago
I've found a way round this. Add this to the TextEntry: ->getStateUsing(fn ($record) => $record->account->name ?? null)