Showing icon in Infolist TextEntry when the value is null

I'm toying with a Infolist and displaying some content using TextEntry. I wanted to add an icon for each TextEntry, but it seems it only shows when the value isn't null. Is there a way to show it even when the placeholder is shown ? Here's my snippet:
TextEntry::make('repartition_key')
->label('Repartition key')
->fontFamily(FontFamily::Mono)
->placeholder('None')
->icon('phosphor-key')
->iconPosition(IconPosition::Before),
TextEntry::make('repartition_key')
->label('Repartition key')
->fontFamily(FontFamily::Mono)
->placeholder('None')
->icon('phosphor-key')
->iconPosition(IconPosition::Before),
Thanks for your help
6 Replies
toeknee
toeknee2w ago
try ->default() or ->formatState() I haven't used TextEntry personally but along those lines
Nicolas Hedger
Nicolas HedgerOP2w ago
Thanks, I've already tried default, i should have mentioned it. My concern is that it hides the placeholder which i want to display when the value is missing. It may be that rendering the icon is conditioned to the presence of the value, not sure if it is intentional
toeknee
toeknee2w ago
But the placeholder can be the default value? if default and placeholder didn't work. Just do:
->formatStateUsing(fn($record) => $record->repartition_key ? '-' : 'None')
->formatStateUsing(fn($record) => $record->repartition_key ? '-' : 'None')
Nicolas Hedger
Nicolas HedgerOP2w ago
Right, but don't you loose the placeholder styling this way ?
toeknee
toeknee2w ago
Ahh I see, place holder styling has a slightly duller approach? so does the placeholder show still but without the icon? If so, I would suggest a PR or Bug Report, since if a placeholder is showing, the icon should show I suspect.
Nicolas Hedger
Nicolas HedgerOP2w ago
Yes, the placeholder is correctly displayed, but the icon is only displayed when the place holder isnt, and there is a value. I'll open a PR, thanks !

Did you find this page helpful?