F
Filament2mo ago
Ava

PHP inside of HtmlString?

I am trying to include the domain within the HtmlString but its a modal from a table. So each modal has its only domain.
->modalDescription(new HtmlString('Paste your Username from <a href="'. $record->url .'">'. $record->name .' </a>\'s user page' ) )
->modalDescription(new HtmlString('Paste your Username from <a href="'. $record->url .'">'. $record->name .' </a>\'s user page' ) )
If Vanilla PHP this is easily doable but that doesnt seem to be the case.
Solution:
->modalDescription(function($record) { return new HtmlString(); })
->modalDescription(function($record) { return new HtmlString(); })
...
Jump to solution
7 Replies
awcodes
awcodes2mo ago
You need to do it as a callback so you can inject the record then return the html string from the closure.
Ava
AvaOP2mo ago
Can you give me an example of this?
Solution
awcodes
awcodes2mo ago
->modalDescription(function($record) { return new HtmlString(); })
->modalDescription(function($record) { return new HtmlString(); })
awcodes
awcodes2mo ago
This assume the modal has a record though. Not sure what action you are calling or where.
Ava
AvaOP2mo ago
Thank you @awcodes - I am new to filament from vanilla PHP so it is taking alot for me to wrap my head around all of these shorthand codes.
awcodes
awcodes2mo ago
No worries. Hang in there it’ll get easier.
Want results from more Discord servers?
Add your server