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

BelongsTo issues #5928

Closed
LorenzoSapora opened this issue Oct 4, 2023 · 1 comment
Closed

BelongsTo issues #5928

LorenzoSapora opened this issue Oct 4, 2023 · 1 comment
Labels
bug Verified bug by the Nova team

Comments

@LorenzoSapora
Copy link

LorenzoSapora commented Oct 4, 2023

  • Nova Version: latest

Description:

BelongsTo display issues when using fieldsForCreate and others.

Recreate

  • Create resource
[..]
class Thing extends Resource
{
[..]

    public function fieldsForIndex()
    {
        return [
            BelongsTo::make('User')
                ->displayUsing(fn() => Str::limit($this->title, 2))
        ];
    }

    public function fieldsForDetail()
    {
        return [
            BelongsTo::make('User')
                ->displayUsing(fn() => Str::limit($this->title, 5))
        ];
    }

    public function fieldsForCreate()
    {
        return [
            BelongsTo::make('User')
                ->displayUsing(fn() => Str::limit($this->title, 10))];
    }

    public function fields()
    {
        return [
            // Leave this blank
        ];
    }

[..]
}

The above will not display the belongsTo output correctly in the create method. The only way to fix is to put a blank BelongsTo into fields(). Some other weirdness happens if you don't put the BelongsTo into the fields(), but I'm hoping the fix for the above fixes the other issues, too.

@crynobone crynobone added the documentation Documentation issue label Oct 4, 2023
@davidhemphill davidhemphill added bug Verified bug by the Nova team and removed documentation Documentation issue labels Nov 29, 2023
Copy link

github-actions bot commented Dec 6, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team
Projects
None yet
Development

No branches or pull requests

3 participants