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

Salut tlm, I have a 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?
No description
Solution:
God I'm an idiot - I'm typing the return as string - change it to HTMLString and all is good. Quack Quack, thanks for listening!
Jump to solution
1 Reply
Solution
Blackpig
Blackpig4mo ago
God I'm an idiot - I'm typing the return as string - change it to HTMLString and all is good. Quack Quack, thanks for listening!
Want results from more Discord servers?
Add your server