F
Filament12mo ago
Harvey

TextEntry placeholder not working for related models

TextEntry::make('book.description')
->placeholder('None'),
TextEntry::make('book.description')
->placeholder('None'),
This should show "None" but is blank. I can see in
vendor/filament/infolists/resources/views/components/text-entry.blade.php::65
vendor/filament/infolists/resources/views/components/text-entry.blade.php::65
the state get's wrapped, which is causing it to be [ 0 => "" ] which resolves to true when deciding whether or not to show the placeholder. is this a bug?
3 Replies
Harvey
HarveyOP12mo ago
public function book(): BelongsTo
{
return $this->belongsTo(Book::class);
}
public function book(): BelongsTo
{
return $this->belongsTo(Book::class);
}
$table->text('description')->nullable();
$table->text('description')->nullable();
bernhard
bernhard12mo ago
Not sure, but this sounds like a bug or so. You could make a PR. As a quick solution you could use formatStateUsing or something
CalumThomson
CalumThomson11mo ago
I too had this issue, but have just upgraded to Filament v3.2.31 and the issue appears to have been resolved in one of the recent versions - I am now seeing the correct placeholder('...') text appear in tables for related model fields that are empty (NULL).

Did you find this page helpful?