Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

afterColumn() doesn't work from custom trait. #5498

Open
karandatwani92 opened this issue Apr 15, 2024 · 0 comments
Open

afterColumn() doesn't work from custom trait. #5498

karandatwani92 opened this issue Apr 15, 2024 · 0 comments
Assignees
Labels
enhancement Possible Bug A bug that was reported but not confirmed yet.

Comments

@karandatwani92
Copy link
Contributor

Discussed in Laravel-Backpack/community-forum#904

Originally posted by cdo9 March 29, 2024
Hello, this is my "setupHasStatusDefaults" function code from my "HasStatusOperation" trait :

$this->crud->operation('list', function () {
    $this->crud->addColumn([
        'name' => 'status',
        'label' => 'status',
        'type' => 'enum',
    ])->afterColumn('id');
});

The column is added, but before any column (first one). Maybe because the HasStatusOperation is loaded before the setupListOperation ? Is there a way to do it after ? I would love to make operations like that to add columns/filters/fields to CRUDs that need it.

EDIT : for now I added ->makeFirst(); to my ID column, so this does the trick to put the field in 2nd

Hey @pxpm

Please take a look at the details in the above discussion.

I tested it and the user is right. I also thought the list closure runs in the setup() before setupListOperation, so I removed setupListOperation() and moved columns in the list closure inside setup() of CRUD. Still the same result.

Apart from this, I also found:

  • CRUD::addColumn('number')->afterColumn('series'); works ✅
  • CRUD::column('number')->afterColumn('series'); - This adds column but afterColumn() doesn't works.❌
@karandatwani92 karandatwani92 added enhancement Possible Bug A bug that was reported but not confirmed yet. labels Apr 15, 2024
@karandatwani92 karandatwani92 transferred this issue from Laravel-Backpack/community-forum Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Possible Bug A bug that was reported but not confirmed yet.
Projects
Status: No status
Development

No branches or pull requests

2 participants