TextEntry with static url, how to set text of anchor tag?

I have an infolist that I'm trying to add a link to like so:
TextEntry::make('myLink')
->label('Do Something')
->url(function (Model $reference) {
$id = $reference->id;
return "https://somedomain.com/somepath?someid={$id}"; })
->openUrlInNewTab(),
TextEntry::make('myLink')
->label('Do Something')
->url(function (Model $reference) {
$id = $reference->id;
return "https://somedomain.com/somepath?someid={$id}"; })
->openUrlInNewTab(),
The a tag is in the dom, but there's no text, so it's not showing up as anything. I'm sure I'm missing something stupid, but it doesn't appear to be in the docs, and looking at the source code, I don't see a method to set the text. ->label() isn't doing it.
Solution:
If it’s not tied to a field on the record then it has no state. So you would need to provide that state via getStateUsing()
Jump to solution
3 Replies
Jon Mason
Jon MasonOP8mo ago
I tried doing this as an alternative:
->html(function (Model $reference) {
$id = $reference->id;
return new HtmlString('<a href="https://somedomain.com/somepath?someid={$id}">View my stupid link</a>'; })
->html(function (Model $reference) {
$id = $reference->id;
return new HtmlString('<a href="https://somedomain.com/somepath?someid={$id}">View my stupid link</a>'; })
and using that method, the a tag isn't even in the rendered dom.
Solution
awcodes
awcodes8mo ago
If it’s not tied to a field on the record then it has no state. So you would need to provide that state via getStateUsing()
Jon Mason
Jon MasonOP8mo ago
that did it, thank you..
Want results from more Discord servers?
Add your server