© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
Blackpig

Dynamic placeholder content renders HTML as text string not mark-up

Salut tlm,

I have a
Placeholder
Placeholder
field that dynamically updates when a user a selects a venue to show an address.
However, the placeholder renders the mark up as a string when updating the content dynamically.
dynamically.

Snip[pets to follow:

The Venue Select
Select::make('venue_id')
->relationship('venue', 'name')
->columnSpan(2)
->live()
->required()
Select::make('venue_id')
->relationship('venue', 'name')
->columnSpan(2)
->live()
->required()

The Placeholder for the Address
 Placeholder::make('venue_address')
//->content(new HtmlString('<p>Addr1<br />Addr2</p>')),  This works
->content(function (GET $get): string {
  $venueId = $get('venue_id');
  return ($venueId && $venue = Venue::find($venueId)) ? new HtmlString($venue->display_address) : '';
}), 
 Placeholder::make('venue_address')
//->content(new HtmlString('<p>Addr1<br />Addr2</p>')),  This works
->content(function (GET $get): string {
  $venueId = $get('venue_id');
  return ($venueId && $venue = Venue::find($venueId)) ? new HtmlString($venue->display_address) : '';
}), 


The Venue Model mutator
protected function displayAddress(): Attribute
    {
        return Attribute::make(
            get: function() {
                $addr = explode(PHP_EOL, $this->address);
                $fullAddr = array_merge($addr, [$this->town, $this->postcode]);
                return implode('<br />', array_filter($fullAddr));
            },
        );
    }
protected function displayAddress(): Attribute
    {
        return Attribute::make(
            get: function() {
                $addr = explode(PHP_EOL, $this->address);
                $fullAddr = array_merge($addr, [$this->town, $this->postcode]);
                return implode('<br />', array_filter($fullAddr));
            },
        );
    }

Screen grab of the output attached

Am I doing something fundamentally wrong? Or is this possibly a bug?
Screenshot_2024-08-30_at_20.15.50.png
Solution
God I'm an idiot - I'm typing the return as
string
string
- change it to
HTMLString
HTMLString
and all is good. Quack Quack, thanks for listening!
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Placeholder not rendering custom HTML
FilamentFFilament / ❓┊help
9mo ago
deferLoading Placeholder Text
FilamentFFilament / ❓┊help
3y ago
$set and Placeholder content
FilamentFFilament / ❓┊help
3y ago
Updating placeholder text afterStateUpdated
FilamentFFilament / ❓┊help
2y ago