Crud: Can't edit colums in setupShowOperation

Created on 1 Apr 2020  路  4Comments  路  Source: Laravel-Backpack/CRUD

Bug report

What I did

I modified a column so it will get its value from an relation

What I expected to happen

The existing column will get a new value

What happened

The column remained unchanged

What I've already tried to fix it

I can add colums, with normal values or values from relations.
I cannot modify or remove existing columns in the show view.

Backpack, Laravel, PHP, DB version

PHP 7.4.3 (cli) (built: Feb 20 2020 21:53:46) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

mysql Ver 15.1 Distrib 10.4.12-MariaDB, for debian-linux-gnu (x86_64) using rea
dline 5.2

When I run php artisan backpack:version the output is:
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

LARAVEL VERSION:

v7.3.0@36d8958b5b8058ef0641806e490f91102fdea70d

BACKPACK VERSION:

4.0.58@03432680d8ed839bcbd99ce57aed61bcf7a1b695

triage

Most helpful comment

Okay, i found a workaround.

In setupShowDefaults() i had to set the operationsetting setFromDb to false:

$this->crud->setOperationSetting('setFromDb', false);

Then in setupShowOperation, re-set it with:

 $this->crud->setFromDb();

After that, i could remove/modify the colums.

All 4 comments

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:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (_How do I do X_) - Gitter Chatroom;
  • Long questions (_I have done X and Y and it won't do Z wtf_) - Stackoverflow, using the backpack-for-laravel tag;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

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

Okay, i found a workaround.

In setupShowDefaults() i had to set the operationsetting setFromDb to false:

$this->crud->setOperationSetting('setFromDb', false);

Then in setupShowOperation, re-set it with:

 $this->crud->setFromDb();

After that, i could remove/modify the colums.

Thanks for sharing your solution, @categoryshell . Note that if you want that behaviour for all CRUDs, you can add that setting to your config/backpack/crud.php file:

    'operations' => [

        /*
         * Show Operation
         */
        'show' => [
            // Define the size/looks of the content div for all CRUDs
            // To override per Controller use $this->crud->setShowContentClass('class-string')
            'contentClass' => 'col-md-8',
+
+           // Should the Show operation try to add all columns using setFromDb()?
+           'setFromDb' => false,
        ],

I found a problem related to this.
If you include 'model' => in modify/add column on setupShowOperation then ignores the modification.
Removed 'model' attribute on modifyColumn/addColumn and its show the name instead id of relationship.

Was this page helpful?
0 / 5 - 0 ratings