izica / relations-widgets-for-backpack

Views/widgets for preview laravel relations in laravel backpack
MIT License
28 stars 13 forks source link

Feature request: description field/column for the widget container #9

Closed fronbow closed 2 years ago

fronbow commented 2 years ago

Hi As the title suggests, is it possible to have some kind of field/column to show extra information to the user pertinent to that widget? My use case is that I have a crud panel that has information that can be shared publicly, but the contained widgets should be kept for internal use. If that makes sense...i.e. We hold an organisations public facing contact information, but for internal use we also have individuals direct lines/contact details. Apologies if this is already covered somewhere but I can't seem to find it in any docs!

Cheers

izica commented 2 years ago

@fronbow Hi, sorry, I didn't quite understand you, but I think you can control data/columns in Controller or Model, This can help you:

        $columns = [
            ['name' => 'column1', 'label' => 'Column 1'],
            ['name' => 'column2', 'label' => 'Column 2'],
        ];
        if (backpack_auth()) { // or check role or something else
            $columns[] = ['name' => 'secured_data', 'label' => 'Secured information'];
        }
        $this->data['widgets']['after_content'][] = [
            'type' => 'relation_table',
            'name' => 'orders',
            'label' => 'Orders',
            'backpack_crud' => 'order',
            'columns' => $columns,
        ];

also you can use: relation_table -> columns -> closure relation_panel -> fields -> visible

fronbow commented 2 years ago

Sorry, in hindsight I meant similar to how the html fieldset can have a legend - a description or some span of informative text underneath the title but above the data so that I don't have to keep reminding people that this form is for specific functionality/use-cases?

fronbow commented 2 years ago

It's ok, I found what I was missing - I forgot that widgets can be placed before content. *doh