How do I create an Infolist Link?

I want to add a "download" link to an ImageEntry but ->downloadable() is only available for the FileUpload form component. For example, the following creates a link, but it's not styled nicely (even though I have some basic classes) and seems a little clunky. It also doesn't appear nicely directly below the ImageEntry I have used above.
TextEntry::make('src')
->label('Download')
->hiddenLabel()
->html()
->state(static fn (Model $model): string => "<a href='{$model->src}' class='fi-link fi-link-size-sm text-info' download>Download</a>"),
TextEntry::make('src')
->label('Download')
->hiddenLabel()
->html()
->state(static fn (Model $model): string => "<a href='{$model->src}' class='fi-link fi-link-size-sm text-info' download>Download</a>"),
Solution:
```php ImageEntry::make('src') ->extraImgAttributes([ 'class' => 'w-full h-auto', // @todo make the image full-width of the section. ])...
Jump to solution
6 Replies
krekas
krekas16mo ago
isn't there url() method?
Lara Zeus
Lara Zeus16mo ago
there is and it should works fine
TextEntry::make('name')
->url(url('name'))
->openUrlInNewTab()
TextEntry::make('name')
->url(url('name'))
->openUrlInNewTab()
trovster
trovsterOP16mo ago
Perfect. ->url() will work. It works with ImageEntry.
Solution
trovster
trovster16mo ago
ImageEntry::make('src')
->extraImgAttributes([
'class' => 'w-full h-auto', // @todo make the image full-width of the section.
])
->url(static fn (Model $model): string => $model->src, shouldOpenInNewTab: true),

TextEntry::make('src')
->html()
->state('Download')
->url(static fn (Model $model): string => $model->src, shouldOpenInNewTab: true),
ImageEntry::make('src')
->extraImgAttributes([
'class' => 'w-full h-auto', // @todo make the image full-width of the section.
])
->url(static fn (Model $model): string => $model->src, shouldOpenInNewTab: true),

TextEntry::make('src')
->html()
->state('Download')
->url(static fn (Model $model): string => $model->src, shouldOpenInNewTab: true),
Want results from more Discord servers?
Add your server