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

Fields with closures not attached to Column #18

Closed
LorenzoSapora opened this issue Jan 14, 2020 · 2 comments
Closed

Fields with closures not attached to Column #18

LorenzoSapora opened this issue Jan 14, 2020 · 2 comments

Comments

@LorenzoSapora
Copy link
Contributor

LorenzoSapora commented Jan 14, 2020

I have some purely informational columns, example

Text::make('User Status', function() { return $this->user->status; })

Adding the field name into Column doesn't appear to attach them.

    public function fields(Request $request)
    {
        return [
            Text::make('Status', function () {
                return $this->user->status;
            }),
        ];
    }
    public function cards(Request $request)
    {
        return [
            MegaFilter::make([
                'columns' => [
                    Column::make('Status')->checked(),
                ]
            ])
        ];
    }

Is this a bug, or is it looking for the attribute (i.e. Text::make('Status', 'userStatus'))

@milewski
Copy link
Member

milewski commented Jan 14, 2020

The attribute is always required, without it, I can not match the column with a field, computed fields has no attributes, so instead of

Text::make('Status', function () {
                return $this->user->status;
            }),

you need to do:

Text::make('Status')->resolveUsing(fn()=> $this->user->status)

or

Text::make('Status', 'user->status')
....
Column::make('Status', 'user->status')->checked()

@LorenzoSapora
Copy link
Contributor Author

Of course. Thank you, I've been staring at that for too long :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants