Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.04k stars 885 forks source link

[Bug] ellipsis when render custom html in list operation #5423

Closed LucaMarconiItechEra closed 7 months ago

LucaMarconiItechEra commented 7 months ago

Bug report

What I did

I'm trying to show a custom html in list operation, calling a function in model. List: immagine Model: immagine Helper: immagine

What I expected to happen

I expect the outcome to be shown in full, without ... for all fields. This is abnormal behavior. I believe that by default you should always show the entire string or value and intervene to cut if necessary immagine

What happened

the ellipsis is added, even though the string is not particularly long. (in the doc I read that the default is 50) immagine

What I've already tried to fix it

Adding ->limit(50) in column immagine

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there? YES

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.2, Copyright (c) Zend Technologies with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies

LARAVEL VERSION:

10.38.1.0

BACKPACK PACKAGE VERSIONS:

backpack/activity-log: 2.0.1 backpack/basset: 1.2.2 backpack/crud: 6.4.2 backpack/devtools: 3.0.4 backpack/generators: v4.0.2 backpack/logmanager: v5.0.1 backpack/permissionmanager: 7.1.1 backpack/pro: 2.0.20 backpack/revise-operation: 2.0.0 backpack/theme-tabler: 1.1.2

welcome[bot] commented 7 months ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

karandatwani92 commented 7 months ago

Hey @LucaMarconiItechEra

You have not defined the column type. The return value is a string thus it is acting as a text column.

To show custom HTML you can use custom_html column. This has:

I also noticed that you want to render the model function's return value. For that, use model_function column.

I also tried the text column and the following worked for me to dodge ellipsis:

$this->crud->column([
            'name'  => 'my_custom_html',
            'label' => 'Custom HTML',
            'type'  => 'text',
            'escaped' => false,
            'limit' => 100,
        ])->value( function ($model){
            return '<span class="text-danger">Something Big is coming</span>';
        });

I hope this helps😊