Skip to content

Unable to retrieve data on BelongsTo inside a BelongsToMany fields in edit mode #5078

@kichetof

Description

@kichetof
  • Laravel Version: 9.40.1
  • Nova Version: 4.19.2
  • PHP Version: 8.1.11
  • Database Driver & Version: Sail
  • Operating System and Version: Docker

Description:

When you have a BelongsTo field in a BelongsToMany fields, data aren't retrieved in attach mode: 404 error.
Everything else works perfectly (index data, inline creation)

That's the url with 404 error:
http://localhost/nova-api/collaborators/associatable/job?first=false&search=&withTrashed=false&resourceId=1312&viaResource=collaborators&viaResourceId=1312&viaRelationship=units&component=belongsto.belongs-to-field.job&dependsOn=eyJqb2IiOiIifQ%3D%3D&editing=true&editMode=update

Workaround is to retrieve data and add a Select field with onlyOnForms but we loose the ability to create inline...

Detailed steps to reproduce the issue on a fresh Nova installation:

// collaborator resource field
BelongsToMany::make('Unité', 'units', Unit::class)
                ->fields(new CollaboratorUnitFields)
                ->allowDuplicateRelations(),

// CollaboratorUnitFields
BelongsTo::make('Poste', 'job', Job::class)
                ->showCreateRelationButton()
                ->withoutTrashed(),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions